Fixed null byte match

This commit is contained in:
DomySh
2022-06-22 01:44:25 +02:00
parent 34d6b18ec0
commit 57178ffdb6
2 changed files with 3 additions and 3 deletions

View File

@@ -27,7 +27,7 @@ ADD ./backend/requirements.txt /execute/requirements.txt
RUN pip install --no-cache-dir -r /execute/requirements.txt RUN pip install --no-cache-dir -r /execute/requirements.txt
COPY ./backend/ /execute/ COPY ./backend/ /execute/
RUN c++ -O3 -o proxy/proxy proxy/proxy.cpp -pthread -lboost_system -lboost_regex RUN c++ -O3 -o proxy/proxy proxy/proxy.cpp -pthread -lboost_system
COPY ./config/supervisord.conf /etc/supervisor/supervisord.conf COPY ./config/supervisord.conf /etc/supervisor/supervisord.conf
COPY ./config/nginx.conf /tmp/nginx.conf COPY ./config/nginx.conf /tmp/nginx.conf
COPY ./config/start_nginx.sh /tmp/start_nginx.sh COPY ./config/start_nginx.sh /tmp/start_nginx.sh

View File

@@ -53,7 +53,7 @@ bool filter_data(unsigned char* data, const size_t& bytes_transferred, vector<pa
for (pair<string,regex> ele:blacklist){ for (pair<string,regex> ele:blacklist){
cmatch what; cmatch what;
try{ try{
regex_search(reinterpret_cast<const char*>(data), what, ele.second); regex_search(reinterpret_cast<const char*>(data), reinterpret_cast<const char*>(data)+bytes_transferred, what, ele.second);
if(what.size() > 0){ if(what.size() > 0){
cout << "BLOCKED " << ele.first << endl; cout << "BLOCKED " << ele.first << endl;
return false; return false;
@@ -65,7 +65,7 @@ bool filter_data(unsigned char* data, const size_t& bytes_transferred, vector<pa
for (pair<string,regex> ele:whitelist){ for (pair<string,regex> ele:whitelist){
cmatch what; cmatch what;
try{ try{
regex_search(reinterpret_cast<const char*>(data), what, ele.second); regex_search(reinterpret_cast<const char*>(data),reinterpret_cast<const char*>(data)+bytes_transferred, what, ele.second);
if(what.size() < 0){ if(what.size() < 0){
cout << "BLOCKED " << ele.first << endl; cout << "BLOCKED " << ele.first << endl;
return false; return false;