From 08c3fe8063b0a7e477dee8036ff5409a48c6f9a9 Mon Sep 17 00:00:00 2001 From: Eran Liberty Date: Thu, 5 Dec 2019 13:37:11 +0000 Subject: [PATCH] - memcpy(&id,ri.key,ri.key_len); + memcpy(&id,ri.key,sizeof(id)); The memcpy from the key to the id reliease on the fact that this key *should* be 8 bytes long as it was entered as such a few lines up the code. BUT if someone will change the code to the point this is no longer true, current code can trash the stack which makes debugging very hard while this fix will result in some garbage id, or even page fault. Both are preferable to stack mangaling. --- src/tracking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tracking.c b/src/tracking.c index f7f0fc755..acb97800a 100644 --- a/src/tracking.c +++ b/src/tracking.c @@ -164,7 +164,7 @@ void trackingInvalidateSlot(uint64_t slot) { raxSeek(&ri,"^",NULL,0); while(raxNext(&ri)) { uint64_t id; - memcpy(&id,ri.key,ri.key_len); + memcpy(&id,ri.key,sizeof(id)); client *c = lookupClientByID(id); if (c == NULL || !(c->flags & CLIENT_TRACKING)) continue; sendTrackingMessage(c,slot);