libctf: Don't construct pointers to out of bounds array offsets

Just attempting to do the pointer arithmetic is undefined behavior.

No functional change intended.

Reported by:	Coverity
Sponsored by:	Dell EMC Isilon
This commit is contained in:
Conrad Meyer 2018-03-26 22:02:36 +00:00
parent e796cc77c5
commit f5147e312f

View File

@ -59,10 +59,12 @@ isqualifier(const char *s, size_t len)
};
int h = s[len - 1] + (int)len - 105;
const struct qual *qp = &qhash[h];
const struct qual *qp;
return (h >= 0 && h < sizeof (qhash) / sizeof (qhash[0]) &&
len == qp->q_len && strncmp(qp->q_name, s, qp->q_len) == 0);
if (h < 0 || h >= sizeof (qhash) / sizeof (qhash[0]))
return (0);
qp = &qhash[h];
return (len == qp->q_len && strncmp(qp->q_name, s, qp->q_len) == 0);
}
/*