some basic checks to prevent reading past buffer size for labels and attrs