From 51ab89d8998e3f6844f72e020e53200e80fe52f7 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 21 Aug 2012 15:06:06 +0200 Subject: [PATCH] Max depth of multi-bulk reply moved from 2 to 7. 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). --- hiredis.c | 6 +++--- hiredis.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hiredis.c b/hiredis.c index f1d018896..41db9e8b2 100644 --- a/hiredis.c +++ b/hiredis.c @@ -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; } diff --git a/hiredis.h b/hiredis.h index accf6b229..b922831e3 100644 --- a/hiredis.h +++ b/hiredis.h @@ -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 */