mirror of
https://github.com/fluencelabs/redis
synced 2025-04-02 15:51:05 +00:00
Streams: fix xreadGetKeys() buffer overflow.
The loop allocated a buffer for the right number of keys positions, then overflowed it going past the limit. Related to #4857 and cause of the memory violation seen in #5028.
This commit is contained in:
parent
62f9ac6f43
commit
a0b27dae85
2
src/db.c
2
src/db.c
@ -1422,7 +1422,7 @@ int *xreadGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys)
|
|||||||
there are also the IDs, one per key. */
|
there are also the IDs, one per key. */
|
||||||
|
|
||||||
keys = zmalloc(sizeof(int) * num);
|
keys = zmalloc(sizeof(int) * num);
|
||||||
for (i = streams_pos+1; i < argc; i++) keys[i-streams_pos-1] = i;
|
for (i = streams_pos+1; i < argc-num; i++) keys[i-streams_pos-1] = i;
|
||||||
*numkeys = num;
|
*numkeys = num;
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user