Unverified Commit 78025c4a authored by yiyuaner's avatar yiyuaner Committed by GitHub
Browse files

Add checks for overflow in redis-check-aof and loadAppendOnlyFile (#9669)


Co-authored-by: default avatarguoyiyuan <guoyiyuan@sbrella.com>
parent 87321deb
...@@ -783,6 +783,7 @@ int loadAppendOnlyFile(char *filename) { ...@@ -783,6 +783,7 @@ int loadAppendOnlyFile(char *filename) {
if (buf[1] == '\0') goto readerr; if (buf[1] == '\0') goto readerr;
argc = atoi(buf+1); argc = atoi(buf+1);
if (argc < 1) goto fmterr; if (argc < 1) goto fmterr;
if ((size_t)argc > SIZE_MAX / sizeof(robj*)) goto fmterr;
/* Load the next command in the AOF as our fake client /* Load the next command in the AOF as our fake client
* argv. */ * argv. */
......
...@@ -124,6 +124,11 @@ int readString(FILE *fp, char** target) { ...@@ -124,6 +124,11 @@ int readString(FILE *fp, char** target) {
return 0; return 0;
} }
if (len < 0 || len > LONG_MAX - 2) {
ERROR("Expected to read string of %ld bytes, which is not in the suitable range",len);
return 0;
}
/* Increase length to also consume \r\n */ /* Increase length to also consume \r\n */
len += 2; len += 2;
*target = (char*)zmalloc(len); *target = (char*)zmalloc(len);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment