From d31217ba1f995e94fbb418bb8fc4ce63f5dc76a7 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Fri, 29 Sep 2017 15:06:36 +0900 Subject: [PATCH] Fix SVACE defect in IoT.js (fs.scandir) [Philippe Coval] While updating IoT.js in Tizen:RT, I noticed this downstream patch, it still applies to current version of IoT.js so I am forwarding it upstream in libtuv. To help tracking I am adding references to this changes. Author: Sanggyu Lee Bug-TizenRT: https://github.com/Samsung/TizenRT/pull/2018 Cc: @juitem Cc: @glistening Change-Id: I16cbca383d4e5a7a8cc36eace93999a622f19adc Forwarded: https://github.com/Samsung/libtuv/pull/122 Origin: https://github.com/Samsung/TizenRT/pull/744 libtuv-DCO-1.0-Signed-off-by: Philippe Coval philippe.coval@osg.samsung.com --- src/unix/fs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/unix/fs.c b/src/unix/fs.c index a9b1531a..4de78590 100644 --- a/src/unix/fs.c +++ b/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);