Merge pull request #1982 from mattsta/fix-getrange-32bit
Increase size of range request in getrange
This commit is contained in:
commit
0019479f86
@ -231,13 +231,13 @@ void setrangeCommand(redisClient *c) {
|
|||||||
|
|
||||||
void getrangeCommand(redisClient *c) {
|
void getrangeCommand(redisClient *c) {
|
||||||
robj *o;
|
robj *o;
|
||||||
long start, end;
|
long long start, end;
|
||||||
char *str, llbuf[32];
|
char *str, llbuf[32];
|
||||||
size_t strlen;
|
size_t strlen;
|
||||||
|
|
||||||
if (getLongFromObjectOrReply(c,c->argv[2],&start,NULL) != REDIS_OK)
|
if (getLongLongFromObjectOrReply(c,c->argv[2],&start,NULL) != REDIS_OK)
|
||||||
return;
|
return;
|
||||||
if (getLongFromObjectOrReply(c,c->argv[3],&end,NULL) != REDIS_OK)
|
if (getLongLongFromObjectOrReply(c,c->argv[3],&end,NULL) != REDIS_OK)
|
||||||
return;
|
return;
|
||||||
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.emptybulk)) == NULL ||
|
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.emptybulk)) == NULL ||
|
||||||
checkType(c,o,REDIS_STRING)) return;
|
checkType(c,o,REDIS_STRING)) return;
|
||||||
@ -255,11 +255,11 @@ void getrangeCommand(redisClient *c) {
|
|||||||
if (end < 0) end = strlen+end;
|
if (end < 0) end = strlen+end;
|
||||||
if (start < 0) start = 0;
|
if (start < 0) start = 0;
|
||||||
if (end < 0) end = 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
|
/* Precondition: end >= 0 && end < strlen, so the only condition where
|
||||||
* nothing can be returned is: start > end. */
|
* nothing can be returned is: start > end. */
|
||||||
if (start > end) {
|
if (start > end || strlen == 0) {
|
||||||
addReply(c,shared.emptybulk);
|
addReply(c,shared.emptybulk);
|
||||||
} else {
|
} else {
|
||||||
addReplyBulkCBuffer(c,(char*)str+start,end-start+1);
|
addReplyBulkCBuffer(c,(char*)str+start,end-start+1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user