diff options
author | George Hazan <ghazan@miranda.im> | 2019-07-25 13:11:56 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-07-25 13:12:04 +0300 |
commit | 9ff49558ea374a70cdb6fd6d16cf75dbf05d4fed (patch) | |
tree | 63d91da1e1fd00874d19319913157b21a98fcfc9 /src/mir_app | |
parent | 72f26fe02475f0735b569ce7ba9d36ad22570605 (diff) |
suspicious code removed
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/netlibhttp.cpp | 8 | ||||
-rw-r--r-- | src/mir_app/src/netliblog.cpp | 56 |
2 files changed, 21 insertions, 43 deletions
diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp index 5d37580e86..52e92a56f2 100644 --- a/src/mir_app/src/netlibhttp.cpp +++ b/src/mir_app/src/netlibhttp.cpp @@ -771,13 +771,13 @@ MIR_APP_DLL(NETLIBHTTPREQUEST*) Netlib_RecvHttpHeaders(HNETLIBCONN hConnection, }
}
- // Receive headers
if (bytesPeeked <= 0) {
NetlibLeaveNestedCS(&nlc->ncsRecv);
Netlib_FreeHttpRequest(nlhr);
return nullptr;
}
+ // Receive headers
nlhr->headersCount = headersCount;
nlhr->headers = (NETLIBHTTPHEADER*)mir_calloc(sizeof(NETLIBHTTPHEADER) * headersCount);
@@ -802,10 +802,8 @@ MIR_APP_DLL(NETLIBHTTPREQUEST*) Netlib_RecvHttpHeaders(HNETLIBCONN hConnection, }
// remove processed data
- if (bytesPeeked > 0) {
- buf.remove(bytesPeeked);
- nlc->foreBuf.appendBefore(buf.data(), buf.length());
- }
+ buf.remove(bytesPeeked);
+ nlc->foreBuf.appendBefore(buf.data(), buf.length());
NetlibLeaveNestedCS(&nlc->ncsRecv);
return nlhr;
diff --git a/src/mir_app/src/netliblog.cpp b/src/mir_app/src/netliblog.cpp index 3680817de9..fd8858fa92 100644 --- a/src/mir_app/src/netliblog.cpp +++ b/src/mir_app/src/netliblog.cpp @@ -411,10 +411,6 @@ MIR_APP_DLL(int) Netlib_LogW(HNETLIBUSER hUser, const wchar_t *pwszStr) void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int flags)
{
- char szTitleLine[128];
- char *szBuf;
- bool useStack = false;
-
// This section checks a number of conditions and aborts
// the dump if the data should not be written to the log
@@ -432,13 +428,13 @@ void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int fla if ((flags & MSG_DUMPSSL) && !logOptions.dumpSsl)
return;
+ CMStringA str;
+
WaitForSingleObject(hConnectionHeaderMutex, INFINITE);
NetlibUser *nlu = nlc ? nlc->nlu : nullptr;
- int titleLineLen;
- if (flags & MSG_NOTITLE)
- titleLineLen = 0;
- else
- titleLineLen = mir_snprintf(szTitleLine, "(%p:%u) Data %s%s\r\n", nlc, nlc ? nlc->s : 0, sent ? "sent" : "received", flags & MSG_DUMPPROXY ? " (proxy)" : "");
+
+ if (!(flags & MSG_NOTITLE))
+ str.Format("(%p:%u) Data %s%s\r\n", nlc, nlc ? nlc->s : 0, sent ? "sent" : "received", flags & MSG_DUMPPROXY ? " (proxy)" : "");
ReleaseMutex(hConnectionHeaderMutex);
// check filter settings
@@ -466,59 +462,43 @@ void NetlibDumpData(NetlibConnection *nlc, PBYTE buf, int len, int sent, int fla // Text data
if (isText) {
- int sz = titleLineLen + len + 1;
- useStack = sz <= 8192;
- szBuf = (char*)(useStack ? alloca(sz) : mir_alloc(sz));
- memcpy(szBuf, szTitleLine, titleLineLen);
- memcpy(szBuf + titleLineLen, (const char*)buf, len);
- szBuf[titleLineLen + len] = '\0';
+ str.Append((const char*)buf, len);
}
// Binary data
else {
int line, col, colsInLine;
- int sz = titleLineLen + ((len + 16) >> 4) * 78 + 1;
- useStack = sz <= 8192;
- szBuf = (char*)(useStack ? alloca(sz) : mir_alloc(sz));
- memcpy(szBuf, szTitleLine, titleLineLen);
- char *pszBuf = szBuf + titleLineLen;
for (line = 0;; line += 16) {
colsInLine = min(16, len - line);
-
if (colsInLine == 16) {
PBYTE p = buf + line;
- pszBuf += wsprintfA(
- pszBuf, "%08X: %02X %02X %02X %02X-%02X %02X %02X %02X-%02X %02X %02X %02X-%02X %02X %02X %02X ",
- line, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); //!!!!!!!!!!
+ str.AppendFormat("%08X: %02X %02X %02X %02X-%02X %02X %02X %02X-%02X %02X %02X %02X-%02X %02X %02X %02X ",
+ line, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
}
else {
- pszBuf += wsprintfA(pszBuf, "%08X: ", line); //!!!!!!!!!!
+ str.AppendFormat("%08X: ", line);
// Dump data as hex
for (col = 0; col < colsInLine; col++)
- pszBuf += wsprintfA(pszBuf, "%02X%c", buf[line + col], ((col & 3) == 3 && col != 15) ? '-' : ' '); //!!!!!!!!!!
+ str.AppendFormat("%02X%c", buf[line + col], ((col & 3) == 3 && col != 15) ? '-' : ' ');
// Fill out last line with blanks
- for (; col < 16; col++) {
- mir_strcpy(pszBuf, " ");
- pszBuf += 3;
- }
- *pszBuf++ = ' ';
+ for (; col < 16; col++)
+ str.Append(" ");
+
+ str.AppendChar(' ');
}
for (col = 0; col < colsInLine; col++)
- *pszBuf++ = (buf[line + col] < ' ') ? '.' : (char)buf[line + col];
+ str.AppendChar((buf[line + col] < ' ') ? '.' : (char)buf[line + col]);
if (len - line <= 16)
break;
- *pszBuf++ = '\r'; // End each line with a break
- *pszBuf++ = '\n'; // End each line with a break
+ str.AppendChar('\r'); // End each line with a break
+ str.AppendChar('\n'); // End each line with a break
}
- *pszBuf = '\0';
}
- NetlibLog_Worker(nlu, szBuf, flags);
- if (!useStack)
- mir_free(szBuf);
+ NetlibLog_Worker(nlu, str, flags);
}
void NetlibLogInit(void)
|