Skip to content

Commit

Permalink
Handle large getrange requests
Browse files Browse the repository at this point in the history
Previously the end was casted to a smaller type
which resulted in a wrong check and failed
with values larger than handled by unsigned.

Closes #1847, #1844
  • Loading branch information
badboy authored and mattsta committed Aug 2, 2014
1 parent 4b54b1e commit f62cb0e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/t_string.c
Expand Up @@ -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 ((unsigned)end >= strlen) end = strlen-1;
if ((size_t)end >= strlen) end = strlen-1;

/* Precondition: end >= 0 && end < strlen, so the only condition where
* nothing can be returned is: start > end. */
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/basic.tcl
Expand Up @@ -769,4 +769,9 @@ start_server {tags {"basic"}} {
r keys *
r keys *
} {dlskeriewrioeuwqoirueioqwrueoqwrueqw}

test {GETRANGE with huge ranges, Github issue #1844} {
r set foo bar
r getrange foo 0 4294967297
} {bar}
}

0 comments on commit f62cb0e

Please sign in to comment.