From 1b013abe2d06bf0cd8a2f852546edef61d172bfa Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Tue, 22 Jan 2019 14:29:03 -0800 Subject: [PATCH] Updated behavior so if agent update is disabled, it will send an agent hash of all zeros to the server, when asked for agent hash. This fixes a bug where the new version of the server only pushes a core, if the hash check succeeds. --- meshcore/agentcore.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/meshcore/agentcore.c b/meshcore/agentcore.c index b79f072..c3d4b22 100644 --- a/meshcore/agentcore.c +++ b/meshcore/agentcore.c @@ -2390,14 +2390,19 @@ void MeshServer_ProcessCommand(ILibWebClient_StateObject WebStateObject, MeshAge } case MeshCommand_AgentHash: { - if (agent->disableUpdate != 0) { break; } - // This is a request for the hash of the agent binary // Built the response that includes our self hash MeshCommand_BinaryPacket_CoreModule *rcm = (MeshCommand_BinaryPacket_CoreModule*)ILibScratchPad2; rcm->command = htons(MeshCommand_AgentHash); // MeshCommand_AgentHash (12), SHA384 hash of the agent executable rcm->request = htons(requestid); // Request id - memcpy_s(rcm->coreModuleHash, sizeof(rcm->coreModuleHash), agent->agentHash, UTIL_SHA384_HASHSIZE);// SHA384 hash of the agent executable + if (agent->disableUpdate != 0) + { + memset(rcm->coreModuleHash, 0, UTIL_SHA384_HASHSIZE); + } + else + { + memcpy_s(rcm->coreModuleHash, sizeof(rcm->coreModuleHash), agent->agentHash, UTIL_SHA384_HASHSIZE);// SHA384 hash of the agent executable + } // Send the self hash back to the server ILibWebClient_WebSocket_Send(WebStateObject, ILibWebClient_WebSocket_DataType_BINARY, (char*)rcm, sizeof(MeshCommand_BinaryPacket_CoreModule), ILibAsyncSocket_MemoryOwnership_USER, ILibWebClient_WebSocket_FragmentFlag_Complete);