From a03cc61df4964a782e149def544c621fe2cd8e32 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Thu, 12 May 2016 02:32:23 +0000 Subject: 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 --- lib/libc/tests/nss/gethostby_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/libc/tests/nss/gethostby_test.c b/lib/libc/tests/nss/gethostby_test.c index bdeafbcdf693..618f7470920b 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], -- cgit v1.2.3