]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1576 in SNORT/snort3 from ~BRASTULT/snort3:readdir_fix to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 12 Apr 2019 02:04:06 +0000 (22:04 -0400)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 12 Apr 2019 02:04:06 +0000 (22:04 -0400)
Squashed commit of the following:

commit 4a75e6c93019765a716eb97e8e9d270f4f4b66dc
Author: Brandon Stultz <brastult@cisco.com>
Date:   Thu Apr 11 21:11:07 2019 -0400

    helpers: directory: use readdir instead of readdir_r

src/helpers/directory.cc

index e1c64b5b10658f45572dae4a84784278f129a9e2..0d85b4182e38fb90d53e9dfa34b2bfaacc4fecc3 100644 (file)
@@ -77,21 +77,18 @@ const char* Directory::next()
         sub = nullptr;
     }
 
-    struct dirent de, * result;
+    struct dirent* de;
 
-    while ( dir && !readdir_r(dir, &de, &result) )
+    while ( dir && (de = readdir(dir)) )
     {
-        if ( !result )
-            break;
-
         struct stat sb;
 
-        if ( !strncmp(de.d_name, ".", 1) )
+        if ( !strncmp(de->d_name, ".", 1) )
             continue;
 
         path.erase(len);
         path += "/";
-        path += de.d_name;
+        path += de->d_name;
 
         if ( path.size() > PATH_MAX - 1 || stat(path.c_str(), &sb) )
             continue;
@@ -105,7 +102,7 @@ const char* Directory::next()
         {
             continue;
         }
-        else if ( !filter.empty() && fnmatch(filter.c_str(), de.d_name, 0) )
+        else if ( !filter.empty() && fnmatch(filter.c_str(), de->d_name, 0) )
         {
             continue;
         }