From 51262d262dfbace812d858aaed3d8f29df44c5e7 Mon Sep 17 00:00:00 2001 From: Sanggyu Lee Date: Fri, 29 Sep 2017 15:06:36 +0900 Subject: [PATCH] Fix SVACE defect in IoT.js (fs.scandir) --- external/iotjs/deps/libtuv/src/unix/fs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/external/iotjs/deps/libtuv/src/unix/fs.c b/external/iotjs/deps/libtuv/src/unix/fs.c index a364375..df59d29 100644 --- a/external/iotjs/deps/libtuv/src/unix/fs.c +++ b/external/iotjs/deps/libtuv/src/unix/fs.c @@ -407,6 +407,12 @@ static ssize_t uv__fs_scandir(uv_fs_t* req) { cnt++; } + if (cnt > 0 && dents == NULL) { + closedir(dir); + cnt = -1; + goto error; + } + /* Allcoate memory for the directory entries. */ dents = (uv__dirent_t**) malloc(sizeof (uv__dirent_t*) * cnt); -- 2.7.4