Replaced usages of sprintf() in stats sender

This commit is contained in:
alexey.lysiuk 2018-03-14 22:19:33 +02:00
parent f1bfc3514d
commit a9802f82f4

View file

@ -113,18 +113,15 @@ bool I_HTTPRequest(const char* request)
return false; return false;
} }
char buffer[1024]; n = write(sockfd, request, strlen(request));
sprintf(buffer, "%s", request);
Printf("Buffer: %s", buffer);
n = write(sockfd, (char*)buffer, (int)strlen(request));
if (n<0) if (n<0)
{ {
DPrintf(DMSG_ERROR, "Error writing to socket.\n"); DPrintf(DMSG_ERROR, "Error writing to socket.\n");
close(sockfd); close(sockfd);
return false; return false;
} }
bzero(buffer, 1024);
char buffer[1024] = {};
n = read(sockfd, buffer, 1023); n = read(sockfd, buffer, 1023);
close(sockfd); close(sockfd);
DPrintf(DMSG_NOTIFY, "Stats send successful.\n"); DPrintf(DMSG_NOTIFY, "Stats send successful.\n");
@ -273,7 +270,7 @@ void D_DoAnonStats()
if (currentrenderer == 1 && sentstats_hwr_done >= CHECKVERSION) return; if (currentrenderer == 1 && sentstats_hwr_done >= CHECKVERSION) return;
static char requeststring[1024]; static char requeststring[1024];
sprintf(requeststring, "GET /stats.php?render=%i&cores=%i&os=%i&renderconfig=%i HTTP/1.1\nHost: %s\nConnection: close\nUser-Agent: %s %s\n\n", mysnprintf(requeststring, sizeof requeststring, "GET /stats.php?render=%i&cores=%i&os=%i&renderconfig=%i HTTP/1.1\nHost: %s\nConnection: close\nUser-Agent: %s %s\n\n",
GetRenderInfo(), GetCoreInfo(), GetOSVersion(), currentrenderer, sys_statshost.GetHumanString(), GAMENAME, VERSIONSTR); GetRenderInfo(), GetCoreInfo(), GetOSVersion(), currentrenderer, sys_statshost.GetHumanString(), GAMENAME, VERSIONSTR);
DPrintf(DMSG_NOTIFY, "Sending %s", requeststring); DPrintf(DMSG_NOTIFY, "Sending %s", requeststring);
std::thread t1(D_DoHTTPRequest, requeststring); std::thread t1(D_DoHTTPRequest, requeststring);