summaryrefslogtreecommitdiff
path: root/read.c
diff options
context:
space:
mode:
authorMichael Grunder <michael.grunder@gmail.com>2020-05-19 12:56:02 -0700
committerGitHub <noreply@github.com>2020-05-19 12:56:02 -0700
commit5c9f49e2123c5df7148939a70b80cd72e4e59646 (patch)
tree7b91fb91c8f32870028ad564f0503e68921e2e8e /read.c
parent243099ccd24b3a02aa3685abcfac77306a3b7d67 (diff)
Resp3 verbatim string support (#805)
Pull RESP3 verbatim string handling from Redis Fixes #802
Diffstat (limited to 'read.c')
-rw-r--r--read.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/read.c b/read.c
index f6dfef0..835eb65 100644
--- a/read.c
+++ b/read.c
@@ -383,10 +383,18 @@ static int processBulkItem(redisReader *r) {
/* Only continue when the buffer contains the entire bulk item. */
bytelen += len+2; /* include \r\n */
if (r->pos+bytelen <= r->len) {
+ if ((cur->type == REDIS_REPLY_VERB && len < 4) ||
+ (cur->type == REDIS_REPLY_VERB && s[5] != ':'))
+ {
+ __redisReaderSetError(r,REDIS_ERR_PROTOCOL,
+ "Verbatim string 4 bytes of content type are "
+ "missing or incorrectly encoded.");
+ return REDIS_ERR;
+ }
if (r->fn && r->fn->createString)
obj = r->fn->createString(cur,s+2,len);
else
- obj = (void*)REDIS_REPLY_STRING;
+ obj = (void*)(long)cur->type;
success = 1;
}
}
@@ -551,6 +559,9 @@ static int processItem(redisReader *r) {
case '#':
cur->type = REDIS_REPLY_BOOL;
break;
+ case '=':
+ cur->type = REDIS_REPLY_VERB;
+ break;
default:
__redisReaderSetErrorProtocolByte(r,*p);
return REDIS_ERR;
@@ -571,6 +582,7 @@ static int processItem(redisReader *r) {
case REDIS_REPLY_BOOL:
return processLineItem(r);
case REDIS_REPLY_STRING:
+ case REDIS_REPLY_VERB:
return processBulkItem(r);
case REDIS_REPLY_ARRAY:
case REDIS_REPLY_MAP: