Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Apr 2017 14:56:41 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r317372 - head/lib/libc/gen
Message-ID:  <201704241456.v3OEufpT017841@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)



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