From 2689ab2246ba6354c4bc800791274a780b748bd5 Mon Sep 17 00:00:00 2001 From: cora32 Date: Thu, 19 Feb 2015 21:02:49 +0300 Subject: [PATCH] Fake overflows fixed. --- connector.cpp | 45 ++++++++++++++++++--------------------------- finder.cpp | 10 +++++----- mainResources.h | 1 + negatives.txt | 1 + 4 files changed, 25 insertions(+), 32 deletions(-) diff --git a/connector.cpp b/connector.cpp index ea18fb5..1c3b7d5 100644 --- a/connector.cpp +++ b/connector.cpp @@ -1495,15 +1495,6 @@ int Connector::_EstablishConnection(char *ip, int port, char *request, conSTR *C setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *) &linger, sizeof(linger)); int iError, iResult = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)); - //CSSOCKET(sock); - //sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); - //setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char *) &on, sizeof(on)); - //int sResult = connect(sock, (sockaddr*)&sockAddr, sizeof(sockAddr)); - // iError = WSAGetLastError(); - //sResult = send(sock, request, strlen(request), 0); - //char r[128419]; - //recv(sock, r, 128419, 0); - while(sock == INVALID_SOCKET) { if(gDebugMode) stt->doEmitionDebugFoundData("[Invalid socket]: " + QString::number(WSAGetLastError())); @@ -1557,7 +1548,7 @@ int Connector::_EstablishConnection(char *ip, int port, char *request, conSTR *C { if(MapWidgetOpened) stt->doEmitionAddOutData(QString(ip), QString(request)); Activity += strlen(request); - char recvBuff[4096] = {0}; + char recvBuff[8192] = {0}; recvBuff2 = new char[RECV_MAX_SIZE]; ZeroMemory(recvBuff2, RECV_MAX_SIZE); @@ -1565,22 +1556,22 @@ int Connector::_EstablishConnection(char *ip, int port, char *request, conSTR *C int x = 256; while (x > 0) { - ZeroMemory(recvBuff, sizeof(recvBuff)); - x = recvWT(sock, recvBuff, sizeof(recvBuff), gTimeOut, &bTO); + ZeroMemory(recvBuff, 8192); + x = recvWT(sock, recvBuff, 8192, gTimeOut, &bTO); if(x <= 0) break; Activity += x; recvBuffSize += x; if( recvBuffSize > RECV_MAX_SIZE ) - { - delete[] recvBuff2; - recvBuff2 = NULL; - + { CSSOCKET(sock); ++Overl; - CSTR->lowerBuff = new char[11]; - strcpy(CSTR->lowerBuff, "[OVERFLOW]"); - CSTR->size = 10; + CSTR->lowerBuff = new char[recvBuffSize]; + strncpy(CSTR->lowerBuff, recvBuff2, recvBuffSize); + CSTR->size = recvBuffSize; + CSTR->overflow = true; + delete[] recvBuff2; + recvBuff2 = NULL; return 0; }; strncat(recvBuff2, recvBuff, x); @@ -1596,22 +1587,22 @@ int Connector::_EstablishConnection(char *ip, int port, char *request, conSTR *C x = 1; while (x > 0) { - ZeroMemory(recvBuff, sizeof(recvBuff)); - x = recvWT(sock, recvBuff, sizeof(recvBuff), gTimeOut, &bTO); + ZeroMemory(recvBuff, 8192); + x = recvWT(sock, recvBuff, 8192, gTimeOut, &bTO); if(x <= 0) break; Activity += x; recvBuffSize += x; if( recvBuffSize > RECV_MAX_SIZE ) { - delete[] recvBuff2; - recvBuff2 = NULL; - CSSOCKET(sock); ++Overl; - CSTR->lowerBuff = new char[11]; - strcpy(CSTR->lowerBuff, "[OVERFLOW]"); - CSTR->size = 10; + CSTR->lowerBuff = new char[recvBuffSize]; + strncpy(CSTR->lowerBuff, recvBuff2, recvBuffSize); + CSTR->size = recvBuffSize; + CSTR->overflow = true; + delete[] recvBuff2; + recvBuff2 = NULL; return 0; }; strncat(recvBuff2, recvBuff, x); diff --git a/finder.cpp b/finder.cpp index 60e3c02..8b5a69d 100644 --- a/finder.cpp +++ b/finder.cpp @@ -518,7 +518,7 @@ bool ftsBA = true; bool ftsLF = true; bool fOpened = false; -char styleBuff[1024] = {""}; +char styleBuff[1024] = {""}; char topBuff[1024] = {"
.strange .other .BasicAuth .FTP .LowLoads .loginforms .SSH


"}; void fputsf(char *ip, char *port, char *text, int flag, char *msg) { @@ -2007,7 +2007,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P ps->flag = 3; ls->flag = 3; } - else if(strstr(cstr.lowerBuff, "[OVERFLOW]") != NULL) + else if(cstr.overflow == true) { ls->flag = 0; ps->flag = 0; @@ -2139,7 +2139,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P ps->flag = 3; ls->flag = 3; } - else if(strstr(cstr.lowerBuff, "[OVERFLOW]") != NULL) + else if(cstr.overflow == true) { ls->flag = 0; ps->flag = 0; @@ -2235,7 +2235,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P ps->flag = 3; ls->flag = 3; } - else if(strstr(cstr.lowerBuff, "[OVERFLOW]") != NULL) + else if(cstr.overflow == true) { ls->flag = 0; ps->flag = 0; @@ -2318,7 +2318,7 @@ int redirectReconnect(char *cookie, char *ip, int port, char *str, Lexems *ls, P ps->flag = 3; ls->flag = 3; } - else if(strstr(cstr.lowerBuff, "[OVERFLOW]") != NULL) + else if(cstr.overflow == true) { ls->flag = 0; ps->flag = 0; diff --git a/mainResources.h b/mainResources.h index d7d9e14..b764316 100644 --- a/mainResources.h +++ b/mainResources.h @@ -72,6 +72,7 @@ struct lopaStr{ struct conSTR{ char *lowerBuff; int size; + bool overflow = false; }; class Lexems diff --git a/negatives.txt b/negatives.txt index 9776ec0..8ad9782 100644 --- a/negatives.txt +++ b/negatives.txt @@ -1,4 +1,5 @@ yadro.ru +Authorization Required Firewall Authentication required before liveinternet #[Dlink]