summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2017-05-01 00:42:31 +0000
committerpfg <pfg@FreeBSD.org>2017-05-01 00:42:31 +0000
commit57723a7d7f1db867d4acce11b84c8389cefc9acd (patch)
tree7e22a571e38438826731a08c4febf22fca23a9dc /lib/libc/gen
parentc7be2cfcb200eaf9324a541bcef416e4aa947809 (diff)
downloadFreeBSD-src-57723a7d7f1db867d4acce11b84c8389cefc9acd.zip
FreeBSD-src-57723a7d7f1db867d4acce11b84c8389cefc9acd.tar.gz
MFC r317372:
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, and signed/unsigned comparison, by matching the types.
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/scandir.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/libc/gen/scandir.c b/lib/libc/gen/scandir.c
index e31c51d..5566700 100644
--- a/lib/libc/gen/scandir.c
+++ b/lib/libc/gen/scandir.c
@@ -82,8 +82,7 @@ scandir(const char *dirname, struct dirent ***namelist,
#endif
{
struct dirent *d, *p, **names = NULL;
- size_t numitems;
- long arraysz;
+ size_t arraysz, numitems;
DIR *dirp;
if ((dirp = opendir(dirname)) == NULL)
OpenPOWER on IntegriCloud