diff options
author | Conrad Meyer <cem@FreeBSD.org> | 2018-03-26 22:02:36 +0000 |
---|---|---|
committer | Conrad Meyer <cem@FreeBSD.org> | 2018-03-26 22:02:36 +0000 |
commit | f5147e312f43a9050468de539aeafa072caa1a60 (patch) | |
tree | 5ce1c31ec4ac087034b6dc4a1a8e355c0f6c1de8 /cddl/contrib/opensolaris/common/ctf/ctf_lookup.c | |
parent | e796cc77c586c2955b2f3940dbf4991b31e8d289 (diff) | |
download | src-f5147e312f43a9050468de539aeafa072caa1a60.tar.gz src-f5147e312f43a9050468de539aeafa072caa1a60.zip |
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
Notes
Notes:
svn path=/head/; revision=331595
Diffstat (limited to 'cddl/contrib/opensolaris/common/ctf/ctf_lookup.c')
-rw-r--r-- | cddl/contrib/opensolaris/common/ctf/ctf_lookup.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/cddl/contrib/opensolaris/common/ctf/ctf_lookup.c b/cddl/contrib/opensolaris/common/ctf/ctf_lookup.c index f8fa72435591..aa58663309b6 100644 --- a/cddl/contrib/opensolaris/common/ctf/ctf_lookup.c +++ b/cddl/contrib/opensolaris/common/ctf/ctf_lookup.c @@ -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); } /* |