summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tadcore/TADCInterface/TADC_IF.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/tadcore/TADCInterface/TADC_IF.cpp b/tadcore/TADCInterface/TADC_IF.cpp
index 6033592..2095ef7 100644
--- a/tadcore/TADCInterface/TADC_IF.cpp
+++ b/tadcore/TADCInterface/TADC_IF.cpp
@@ -36,6 +36,7 @@
#include <dirent.h>
+#include <cerrno>
#include <memory>
#include "DUIDGenerator.h"
@@ -338,9 +339,7 @@ int AddCertSTOREFromDir(X509_STORE *pstStore, const char *dirPath)
int ret = 0;
DIR *dir = NULL;
- struct dirent entry;
- struct dirent *result;
- int error;
+ struct dirent *result = nullptr;
char file_path_buff[512];
if (pstStore == NULL || dirPath == NULL) {
@@ -358,23 +357,25 @@ int AddCertSTOREFromDir(X509_STORE *pstStore, const char *dirPath)
}
while (true) {
- error = readdir_r(dir, &entry, &result);
-
- if (error != 0) {
- DRM_TAPPS_EXCEPTION("fail to read entries from a directory(%s)!", dirPath);
- ret = -1;
- goto error;
+ errno = 0;
+ result = readdir(dir);
+ if (result == NULL) {
+ if (errno != 0) {
+ DRM_TAPPS_EXCEPTION("fail to read entries from a directory(%s)!",
+ dirPath);
+ ret = -1;
+ goto error;
+ } else {
+ // end of stream
+ break;
+ }
}
- // readdir_r returns NULL in *result if the end
- // of the directory stream is reached
- if (result == NULL)
- break;
-
- if (entry.d_type == DT_REG) { // regular file
+ if (result->d_type == DT_REG) {
+ // regular file
memset(file_path_buff, 0, sizeof(file_path_buff));
snprintf(file_path_buff, sizeof(file_path_buff), "%s/%s", dirPath,
- entry.d_name);
+ result->d_name);
if (AddCertSTOREFromFile(pstStore, file_path_buff) == 0) {
DRM_TAPPS_LOG("Add root cert : file=%s", file_path_buff);