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
This commit is contained in:
Conrad Meyer 2016-05-12 02:32:23 +00:00
parent ac97203f5b
commit a03cc61df4

View File

@ -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],