svn commit: r317372 - head/lib/libc/gen

Pedro F. Giffuni pfg at FreeBSD.org
Mon Apr 24 14:56:42 UTC 2017


Author: pfg
Date: Mon Apr 24 14:56:41 2017
New Revision: 317372
URL: https://svnweb.freebsd.org/changeset/base/317372

Log:
  scandir(3): promote arraysz to size_t to match numitems.
  
  The internal array size goes through a loop and is compared with numitems
  which at its limits makes can be unreachably higher than arraysz.
  Prevent an hypothetical overflow by matching the types.
  
  MFC after:	1 week

Modified:
  head/lib/libc/gen/scandir.c

Modified: head/lib/libc/gen/scandir.c
==============================================================================
--- head/lib/libc/gen/scandir.c	Mon Apr 24 14:51:53 2017	(r317371)
+++ head/lib/libc/gen/scandir.c	Mon Apr 24 14:56:41 2017	(r317372)
@@ -82,8 +82,7 @@ scandir(const char *dirname, struct dire
 #endif
 {
 	struct dirent *d, *p, **names = NULL;
-	size_t numitems;
-	long arraysz;
+	size_t arraysz, numitems;
 	DIR *dirp;
 
 	if ((dirp = opendir(dirname)) == NULL)


More information about the svn-src-head mailing list