From: Russ Combs (rucombs) Date: Fri, 12 Apr 2019 02:04:06 +0000 (-0400) Subject: Merge pull request #1576 in SNORT/snort3 from ~BRASTULT/snort3:readdir_fix to master X-Git-Tag: 3.0.0-253~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6af384c3b01f0abb0e3080a9647d57c01bf8989;p=thirdparty%2Fsnort3.git Merge pull request #1576 in SNORT/snort3 from ~BRASTULT/snort3:readdir_fix to master Squashed commit of the following: commit 4a75e6c93019765a716eb97e8e9d270f4f4b66dc Author: Brandon Stultz Date: Thu Apr 11 21:11:07 2019 -0400 helpers: directory: use readdir instead of readdir_r --- diff --git a/src/helpers/directory.cc b/src/helpers/directory.cc index e1c64b5b1..0d85b4182 100644 --- a/src/helpers/directory.cc +++ b/src/helpers/directory.cc @@ -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; }