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)
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to