summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Stancliff <matt@genges.com>2014-09-02 17:56:17 -0400
committerMatt Stancliff <matt@genges.com>2014-09-02 18:56:01 -0400
commitf0e306f4a0bc0e4db15da54eb3d1d2337a1b6dea (patch)
tree7a1c822aeb7d23b36047dc92d067228eec6f757c
parent67e414c7b871bced5e84f9eb9675a630ed6108dc (diff)
downloadredis-f0e306f4a0bc0e4db15da54eb3d1d2337a1b6dea.tar.gz
Increase size of range request in getrange
32 bit builds don't have a big enough long to capture the same range as a 64 bit build. If we use "long long" we get proper size limits everywhere. Also updates size of unsigned comparison to fit new size of `end`. Fixes #1981
-rw-r--r--src/t_string.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/t_string.c b/src/t_string.c
index 8a4d5f166..2bf772a2d 100644
--- a/src/t_string.c
+++ b/src/t_string.c
@@ -231,13 +231,13 @@ void setrangeCommand(redisClient *c) {
void getrangeCommand(redisClient *c) {
robj *o;
- long start, end;
+ long long start, end;
char *str, llbuf[32];
size_t strlen;
- if (getLongFromObjectOrReply(c,c->argv[2],&start,NULL) != REDIS_OK)
+ if (getLongLongFromObjectOrReply(c,c->argv[2],&start,NULL) != REDIS_OK)
return;
- if (getLongFromObjectOrReply(c,c->argv[3],&end,NULL) != REDIS_OK)
+ if (getLongLongFromObjectOrReply(c,c->argv[3],&end,NULL) != REDIS_OK)
return;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.emptybulk)) == NULL ||
checkType(c,o,REDIS_STRING)) return;
@@ -255,7 +255,7 @@ void getrangeCommand(redisClient *c) {
if (end < 0) end = strlen+end;
if (start < 0) start = 0;
if (end < 0) end = 0;
- if ((size_t)end >= strlen) end = strlen-1;
+ if ((unsigned long long)end >= strlen) end = strlen-1;
/* Precondition: end >= 0 && end < strlen, so the only condition where
* nothing can be returned is: start > end. */