From 57fd36c3221e96dd82061d9f3325fd383d7a8027 Mon Sep 17 00:00:00 2001 From: Nathan Phillips Date: Wed, 22 Mar 2017 13:56:36 +0000 Subject: [PATCH] Prevent recursion into . and .. folders on Alpine Linux --- src/util/file_util.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util/file_util.cpp b/src/util/file_util.cpp index 0a62549316e..50dc06473f4 100644 --- a/src/util/file_util.cpp +++ b/src/util/file_util.cpp @@ -30,6 +30,8 @@ Date: January 2012 #define chdir _chdir #define popen _popen #define pclose _pclose +#else +#include #endif #include "file_util.h" @@ -119,6 +121,9 @@ void delete_directory(const std::string &path) struct dirent *ent; while((ent=readdir(dir))!=NULL) { + // Needed for Alpine Linux + if(strcmp(ent->d_name, ".")==0 || strcmp(ent->d_name, "..")==0) + continue; std::string sub_path=path+"/"+ent->d_name; if(ent->d_type==DT_DIR) delete_directory(sub_path);