summaryrefslogtreecommitdiff
path: root/read.c
diff options
context:
space:
mode:
authorAlex Smith <aes7mv@virginia.edu>2020-10-15 17:55:30 -0400
committermichael-grunder <michael.grunder@gmail.com>2021-02-25 21:25:17 -0800
commit51e693f4fd54d6a9dfbdafa1b361f6618e4f7ba3 (patch)
tree36ddcb0095a5985d799015d69d3504b9efc4a412 /read.c
parent790b4d3b4da0687a475e8a42724fbf6739bbd947 (diff)
read: Add additional RESP3 bool validation
RESP3 bools should be only one of "#t\r\n" or "#f\r\n". We also allow capital 'T' and 'F' to be lenient.
Diffstat (limited to 'read.c')
-rw-r--r--read.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/read.c b/read.c
index 57da853..1378671 100644
--- a/read.c
+++ b/read.c
@@ -331,7 +331,15 @@ static int processLineItem(redisReader *r) {
else
obj = (void*)REDIS_REPLY_NIL;
} else if (cur->type == REDIS_REPLY_BOOL) {
- int bval = p[0] == 't' || p[0] == 'T';
+ int bval;
+
+ if (len != 1 || !strchr("tTfF", p[0])) {
+ __redisReaderSetError(r,REDIS_ERR_PROTOCOL,
+ "Bad bool value");
+ return REDIS_ERR;
+ }
+
+ bval = p[0] == 't' || p[0] == 'T';
if (r->fn && r->fn->createBool)
obj = r->fn->createBool(cur,bval);
else