Skip to content

Commit

Permalink
Max depth of multi-bulk reply moved from 2 to 7.
Browse files Browse the repository at this point in the history
Hiredis can handle multi bulk replies with a fixed (hardcoded) level of
nesting. This should be changed in the future in order to avoid
hardcoded limits. As a quick fix this commit moves the max nesting from 2
to 7, so that there are no problems when processing replies from the SLOWLOG
command, from Redis Sentinel, or generated by Redis Lua Scripts (that are
allowed to generate replies with any level of nesting).
  • Loading branch information
antirez committed Aug 21, 2012
1 parent 7f09505 commit 51ab89d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions hiredis.c
Expand Up @@ -446,10 +446,10 @@ static int processMultiBulkItem(redisReader *r) {
long elements;
int root = 0;

/* Set error for nested multi bulks with depth > 2 */
if (r->ridx == 3) {
/* Set error for nested multi bulks with depth > 7 */
if (r->ridx == 8) {
__redisReaderSetError(r,REDIS_ERR_PROTOCOL,
"No support for nested multi bulk replies with depth > 2");
"No support for nested multi bulk replies with depth > 7");
return REDIS_ERR;
}

Expand Down
2 changes: 1 addition & 1 deletion hiredis.h
Expand Up @@ -129,7 +129,7 @@ typedef struct redisReader {
size_t len; /* Buffer length */
size_t maxbuf; /* Max length of unused buffer */

redisReadTask rstack[4];
redisReadTask rstack[9];
int ridx; /* Index of current read task */
void *reply; /* Temporary reply pointer */

Expand Down

0 comments on commit 51ab89d

Please sign in to comment.