diff --git a/daemon/Child.cpp b/daemon/Child.cpp
index c7848477f79a07dfb283af7468b808c309e7a9fe..286c7e7ba3987540a13db1855a3d9aa5a09ce268 100644 (file)
--- a/daemon/Child.cpp
+++ b/daemon/Child.cpp
}
static void* stopThread(void* pVoid) {
- int length;
- char type;
OlySocket* socket = child->socket;
prctl(PR_SET_NAME, (unsigned long)&"gatord-stopper", 0, 0, 0);
while (gSessionData->mSessionIsActive) {
// This thread will stall until the APC_STOP or PING command is received over the socket or the socket is disconnected
- const int result = socket->receiveNBytes(&type, sizeof(type));
+ unsigned char header[5];
+ const int result = socket->receiveNBytes((char*)&header, sizeof(header));
+ const char type = header[0];
+ const int length = (header[1] << 0) | (header[2] << 8) | (header[3] << 16) | (header[4] << 24);
if (result == -1) {
child->endSession();
} else if (result > 0) {
logg->logMessage("INVESTIGATE: Received unknown command type %d", type);
} else {
// verify a length of zero
- if (socket->receiveNBytes((char*)&length, sizeof(length)) < 0) {
- break;
- }
-
if (length == 0) {
if (type == COMMAND_APC_STOP) {
logg->logMessage("Stop command received.");