Skip to content

Commit 230c8c5

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#672 from NathanJPhillips/bugfix/alpine-linux-directory-recursion
Prevent recursion into . and .. folders on Alpine Linux
2 parents 6edd2b3 + 57fd36c commit 230c8c5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/util/file_util.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Date: January 2012
3030
#define chdir _chdir
3131
#define popen _popen
3232
#define pclose _pclose
33+
#else
34+
#include <cstring>
3335
#endif
3436

3537
#include "file_util.h"
@@ -119,6 +121,9 @@ void delete_directory(const std::string &path)
119121
struct dirent *ent;
120122
while((ent=readdir(dir))!=NULL)
121123
{
124+
// Needed for Alpine Linux
125+
if(strcmp(ent->d_name, ".")==0 || strcmp(ent->d_name, "..")==0)
126+
continue;
122127
std::string sub_path=path+"/"+ent->d_name;
123128
if(ent->d_type==DT_DIR)
124129
delete_directory(sub_path);

0 commit comments

Comments
 (0)