mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 19:47:47 +03:00
Avoids to load a directory structure as a rules file
This commit is contained in:
@@ -144,5 +144,19 @@ bool createDir(std::string dir, int mode, std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool isFile(std::string f) {
|
||||
struct stat fileInfo;
|
||||
FILE *fp = fopen(f.c_str(), "r");
|
||||
fstat(fileno(fp), &fileInfo);
|
||||
if (!S_ISREG(fileInfo.st_mode)) {
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace utils
|
||||
} // namespace modsecurity
|
||||
|
@@ -34,7 +34,7 @@ std::string find_resource(const std::string& file, const std::string& param,
|
||||
std::string get_path(const std::string& file);
|
||||
std::list<std::string> expandEnv(const std::string& var, int flags);
|
||||
bool createDir(std::string dir, int mode, std::string *error);
|
||||
|
||||
bool isFile(std::string f);
|
||||
|
||||
} // namespace utils
|
||||
} // namespace modsecurity
|
||||
|
Reference in New Issue
Block a user