Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 May 2016 02:32:23 +0000 (UTC)
From:      "Conrad E. Meyer" <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r299502 - head/lib/libc/tests/nss
Message-ID:  <201605120232.u4C2WNnL016335@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Thu May 12 02:32:23 2016
New Revision: 299502
URL: https://svnweb.freebsd.org/changeset/base/299502

Log:
  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

Modified:
  head/lib/libc/tests/nss/gethostby_test.c

Modified: head/lib/libc/tests/nss/gethostby_test.c
==============================================================================
--- head/lib/libc/tests/nss/gethostby_test.c	Thu May 12 02:05:50 2016	(r299501)
+++ head/lib/libc/tests/nss/gethostby_test.c	Thu May 12 02:32:23 2016	(r299502)
@@ -893,7 +893,7 @@ hostent_test_getnameinfo_eq(struct hoste
 			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],



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605120232.u4C2WNnL016335>