From 3f89480af0c55e19348cc0c241b9e6daa320feba Mon Sep 17 00:00:00 2001
From: Pawel Andruszkiewicz
Date: Tue, 8 Mar 2016 10:53:13 +0100
Subject: [PATCH] [Tools] Function readdir() replaced with readdir_r().
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
---
src/tool/desc_gentool.cc | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/tool/desc_gentool.cc b/src/tool/desc_gentool.cc
index b06db7b6..c93f5db9 100644
--- a/src/tool/desc_gentool.cc
+++ b/src/tool/desc_gentool.cc
@@ -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_) &&
--
2.34.1