- 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.
This commit is contained in:
Eran Liberty 2019-12-05 13:37:11 +00:00
parent ef5186d920
commit 08c3fe8063
1 changed files with 1 additions and 1 deletions

View File

@ -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);