svn commit: r331595 - head/cddl/contrib/opensolaris/common/ctf
Conrad Meyer
cem at FreeBSD.org
Mon Mar 26 22:02:37 UTC 2018
Author: cem
Date: Mon Mar 26 22:02:36 2018
New Revision: 331595
URL: https://svnweb.freebsd.org/changeset/base/331595
Log:
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
Modified:
head/cddl/contrib/opensolaris/common/ctf/ctf_lookup.c
Modified: head/cddl/contrib/opensolaris/common/ctf/ctf_lookup.c
==============================================================================
--- head/cddl/contrib/opensolaris/common/ctf/ctf_lookup.c Mon Mar 26 21:57:44 2018 (r331594)
+++ head/cddl/contrib/opensolaris/common/ctf/ctf_lookup.c Mon Mar 26 22:02:36 2018 (r331595)
@@ -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);
}
/*
More information about the svn-src-all
mailing list