summaryrefslogtreecommitdiff
path: root/read.c
diff options
context:
space:
mode:
authorAlex Smith <aes7mv@virginia.edu>2020-10-16 18:35:58 -0400
committermichael-grunder <michael.grunder@gmail.com>2021-02-25 21:25:17 -0800
commit83c14504257de168c45ae7730a00c930ab17cfa3 (patch)
tree56b0c640dff32b831c2d883d841b9622c790193a /read.c
parentc6646cb19242b0e0966760b38e7df74742b3a7b2 (diff)
read: Add support for the RESP3 bignum type
Diffstat (limited to 'read.c')
-rw-r--r--read.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/read.c b/read.c
index 89b5b5a..5e0e0b4 100644
--- a/read.c
+++ b/read.c
@@ -337,6 +337,22 @@ static int processLineItem(redisReader *r) {
obj = r->fn->createBool(cur,bval);
else
obj = (void*)REDIS_REPLY_BOOL;
+ } else if (cur->type == REDIS_REPLY_BIGNUM) {
+ /* Ensure all characters are decimal digits (with possible leading
+ * minus sign). */
+ for (int i = 0; i < len; i++) {
+ /* XXX Consider: Allow leading '+'? Error on leading '0's? */
+ if (i == 0 && p[0] == '-') continue;
+ if (p[i] < '0' || p[i] > '9') {
+ __redisReaderSetError(r,REDIS_ERR_PROTOCOL,
+ "Bad bignum value");
+ return REDIS_ERR;
+ }
+ }
+ if (r->fn && r->fn->createString)
+ obj = r->fn->createString(cur,p,len);
+ else
+ obj = (void*)REDIS_REPLY_BIGNUM;
} else {
/* Type will be error or status. */
for (int i = 0; i < len; i++) {
@@ -587,6 +603,9 @@ static int processItem(redisReader *r) {
case '>':
cur->type = REDIS_REPLY_PUSH;
break;
+ case '(':
+ cur->type = REDIS_REPLY_BIGNUM;
+ break;
default:
__redisReaderSetErrorProtocolByte(r,*p);
return REDIS_ERR;
@@ -605,6 +624,7 @@ static int processItem(redisReader *r) {
case REDIS_REPLY_DOUBLE:
case REDIS_REPLY_NIL:
case REDIS_REPLY_BOOL:
+ case REDIS_REPLY_BIGNUM:
return processLineItem(r);
case REDIS_REPLY_STRING:
case REDIS_REPLY_VERB: