summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--read.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/read.c b/read.c
index 0952469..34fce2e 100644
--- a/read.c
+++ b/read.c
@@ -299,13 +299,17 @@ static int processLineItem(redisReader *r) {
memcpy(buf,p,len);
buf[len] = '\0';
- if (strcasecmp(buf,",inf") == 0) {
+ if (strcasecmp(buf,"inf") == 0) {
d = INFINITY; /* Positive infinite. */
- } else if (strcasecmp(buf,",-inf") == 0) {
+ } else if (strcasecmp(buf,"-inf") == 0) {
d = -INFINITY; /* Negative infinite. */
} else {
d = strtod((char*)buf,&eptr);
- if (buf[0] == '\0' || eptr[0] != '\0' || isnan(d)) {
+ /* RESP3 only allows "inf", "-inf", and finite values, while
+ * strtod() allows other variations on infinity, NaN,
+ * etc. We explicity handle our two allowed infinite cases
+ * above, so strtod() should only result in finite values. */
+ if (buf[0] == '\0' || eptr[0] != '\0' || !isfinite(d)) {
__redisReaderSetError(r,REDIS_ERR_PROTOCOL,
"Bad double value");
return REDIS_ERR;