mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
parser: Fix the expanded list inclusion
This commit is contained in:
parent
c98be42f8f
commit
ab88083159
@ -402,7 +402,9 @@ VAR_FREE_TEXT_SPACE_COMMA [^, \t\"]+
|
||||
driver.error (*driver.loc.back(), "", file + std::string(": Not able to open file."));
|
||||
throw p::syntax_error(*driver.loc.back(), "");
|
||||
}
|
||||
for (auto& s: modsecurity::utils::expandEnv(fi, 0)) {
|
||||
std::list<std::string> files = modsecurity::utils::expandEnv(fi, 0);
|
||||
files.reverse();
|
||||
for (auto& s: files) {
|
||||
std::string f = modsecurity::utils::find_resource(s, driver.ref.back());
|
||||
yyin = fopen(f.c_str(), "r" );
|
||||
if (!yyin) {
|
||||
@ -426,7 +428,9 @@ VAR_FREE_TEXT_SPACE_COMMA [^, \t\"]+
|
||||
driver.error (*driver.loc.back(), "", file + std::string(": Not able to open file."));
|
||||
throw p::syntax_error(*driver.loc.back(), "");
|
||||
}
|
||||
for (auto& s: modsecurity::utils::expandEnv(fi, 0)) {
|
||||
std::list<std::string> files = modsecurity::utils::expandEnv(fi, 0);
|
||||
files.reverse();
|
||||
for (auto& s: files) {
|
||||
std::string f = modsecurity::utils::find_resource(s, driver.ref.back());
|
||||
yyin = fopen(f.c_str(), "r" );
|
||||
if (!yyin) {
|
||||
@ -437,7 +441,6 @@ VAR_FREE_TEXT_SPACE_COMMA [^, \t\"]+
|
||||
driver.ref.push_back(f.c_str());
|
||||
driver.loc.push_back(new yy::location());
|
||||
yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE ));
|
||||
|
||||
}
|
||||
free(f);
|
||||
}
|
||||
|
@ -106,8 +106,8 @@ std::string get_path(const std::string& file) {
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> expandEnv(const std::string& var, int flags) {
|
||||
std::vector<std::string> vars;
|
||||
std::list<std::string> expandEnv(const std::string& var, int flags) {
|
||||
std::list<std::string> vars;
|
||||
|
||||
wordexp_t p;
|
||||
if (wordexp(var.c_str(), &p, flags) == false) {
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
#include "modsecurity/modsecurity.h"
|
||||
|
||||
@ -31,7 +31,7 @@ namespace utils {
|
||||
double cpu_seconds(void);
|
||||
std::string find_resource(const std::string& file, const std::string& param);
|
||||
std::string get_path(const std::string& file);
|
||||
std::vector<std::string> expandEnv(const std::string& var, int flags);
|
||||
std::list<std::string> expandEnv(const std::string& var, int flags);
|
||||
void createDir(std::string dir, int mode);
|
||||
|
||||
|
||||
|
@ -37,12 +37,12 @@ void print_help() {
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
modsecurity::Rules *modsecRules = new modsecurity::Rules();
|
||||
std::vector<std::string> files;
|
||||
std::list<std::string> files;
|
||||
int total = 0;
|
||||
|
||||
int i = 1;
|
||||
while (i < argc) {
|
||||
std::vector<std::string> tfiles = modsecurity::utils::expandEnv(
|
||||
std::list<std::string> tfiles = modsecurity::utils::expandEnv(
|
||||
argv[i], 0);
|
||||
for (const auto &file : tfiles) {
|
||||
files.insert(files.begin(), file);
|
||||
|
Loading…
x
Reference in New Issue
Block a user