-
Notifications
You must be signed in to change notification settings - Fork 23.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix redis-cli / redis-sential overflow on some platforms (CVE-2021-32…
…762) (#9587) The redis-cli command line tool and redis-sentinel service may be vulnerable to integer overflow when parsing specially crafted large multi-bulk network replies. This is a result of a vulnerability in the underlying hiredis library which does not perform an overflow check before calling the calloc() heap allocation function. This issue only impacts systems with heap allocators that do not perform their own overflow checks. Most modern systems do and are therefore not likely to be affected. Furthermore, by default redis-sentinel uses the jemalloc allocator which is also not vulnerable. Co-authored-by: Yossi Gottlieb <yossigo@gmail.com>
- Loading branch information
Showing
2 changed files
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -174,6 +174,7 @@ static void *createArrayObject(const redisReadTask *task, size_t elements) { | |
| return NULL; | ||
|
|
||
| if (elements > 0) { | ||
| if (SIZE_MAX / sizeof(redisReply*) < elements) return NULL; /* Don't overflow */ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
yossigo
Author
Member
|
||
| r->element = hi_calloc(elements,sizeof(redisReply*)); | ||
| if (r->element == NULL) { | ||
| freeReplyObject(r); | ||
|
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@yossigo there's a memory leak here now - we need to call freeReplyObject(r) before returning NULL .