summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorcem <cem@FreeBSD.org>2016-05-12 02:32:23 +0000
committercem <cem@FreeBSD.org>2016-05-12 02:32:23 +0000
commitc0a49a226519d7fb434146de32374d2f42078bb9 (patch)
tree745e3d8d5952f0d05a5df98740de5517a163de3c /lib/libc
parentb3857d7c402e06970db2975dfb9c71ba6fd66fe6 (diff)
downloadFreeBSD-src-c0a49a226519d7fb434146de32374d2f42078bb9.zip
FreeBSD-src-c0a49a226519d7fb434146de32374d2f42078bb9.tar.gz
nss/gethostby_test: fix broken vector iteration of gethostbyaddr h_aliases
h_aliases is a NULL-terminated rather than fixed-length array. nitems() is not a valid way to determine its end; instead, check for NULL. Reported by: Coverity CID: 1346578 Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/tests/nss/gethostby_test.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libc/tests/nss/gethostby_test.c b/lib/libc/tests/nss/gethostby_test.c
index bdeafbc..618f747 100644
--- a/lib/libc/tests/nss/gethostby_test.c
+++ b/lib/libc/tests/nss/gethostby_test.c
@@ -893,7 +893,7 @@ hostent_test_getnameinfo_eq(struct hostent *he, void *mdata)
printf("matched official hostname\n");
#endif
} else {
- for (i = 0; i < nitems(result->h_aliases); i++) {
+ for (i = 0; result->h_aliases[i] != NULL; i++) {
printf("[%d] resolved: %s\n", i,
result->h_aliases[i]);
if (strcmp(result->h_aliases[i],
OpenPOWER on IntegriCloud