[Tools] Function readdir() replaced with readdir_r().
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Tue, 8 Mar 2016 09:53:13 +0000 (10:53 +0100)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Tue, 8 Mar 2016 09:53:13 +0000 (10:53 +0100)
Fixes: SVACE 41298
[Verification] This tool is used during compilation of webapi-plugins.
After the modification, package code compiles, plugins run correctly.

Change-Id: I10ae683c6e3ca2589602a9eab35f4429e1a58c85
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/tool/desc_gentool.cc

index b06db7b669fea9f38beb361389efe85420cf6686..c93f5db9e44096155e6ce4078bd053c6c3103558 100644 (file)
@@ -164,10 +164,11 @@ int main(int argc, char* argv[]) {
   }
 
   DIR * dir;
-  struct dirent *ent;
+  struct dirent ent = {0};
+  struct dirent* result = nullptr;
   if ((dir = opendir(tec_path.c_str())) != NULL) {
-    while ((ent = readdir(dir)) != NULL) {
-      std::string fname = ent->d_name;
+    while ((0 == (readdir_r(dir, &ent, &result))) && result) {
+      std::string fname = ent.d_name;
 
       if (fname.size() >= prefix_.size() + postfix_.size() &&
           !fname.compare(0, prefix_.size(), prefix_) &&