Fix SVACE defect in IoT.js (fs.scandir)
authorSanggyu Lee <sg5.lee@samsung.com>
Fri, 29 Sep 2017 06:06:36 +0000 (15:06 +0900)
committerSanggyu Lee <sg5.lee@samsung.com>
Fri, 29 Sep 2017 06:07:22 +0000 (15:07 +0900)
external/iotjs/deps/libtuv/src/unix/fs.c

index a364375..df59d29 100644 (file)
@@ -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);