Merge pull request #221 from minggo/sync-15778

avoid accessing invalid memory
This commit is contained in:
minggo
2016-07-18 18:00:23 +08:00
committed by GitHub
@@ -1850,6 +1850,11 @@ static void serverEntryPoint(unsigned int port)
listen(s, 1);
#define MAX_RECEIVED_SIZE 1024
#define BUF_SIZE MAX_RECEIVED_SIZE + 1
char buf[BUF_SIZE] = {0};
int readBytes = 0;
while (true) {
clientSocket = accept(s, NULL, NULL);
@@ -1866,10 +1871,8 @@ static void serverEntryPoint(unsigned int port)
inData = "connected";
// process any input, send any output
clearBuffers();
char buf[1024] = {0};
int readBytes = 0;
while ((readBytes = (int)::recv(clientSocket, buf, sizeof(buf), 0)) > 0)
while ((readBytes = (int)::recv(clientSocket, buf, MAX_RECEIVED_SIZE, 0)) > 0)
{
buf[readBytes] = '\0';
// TRACE_DEBUGGER_SERVER("debug server : received command >%s", buf);
@@ -1883,6 +1886,9 @@ static void serverEntryPoint(unsigned int port)
cc_closesocket(clientSocket);
}
} // while(true)
#undef BUF_SIZE
#undef MAX_RECEIVED_SIZE
}
bool JSBDebug_BufferWrite(JSContext* cx, unsigned argc, jsval* vp)