mirror of
https://github.com/fluencelabs/redis
synced 2025-05-29 18:21:20 +00:00
Reject MOVE to non-integer DBs
Previously, "MOVE key somestring" would move the key to DB 0 which is just unexpected and wrong. String as DB == error. Test added too. Modified by @antirez in order to use the getLongLongFromObject() API instead of strtol(). Fixes #1428
This commit is contained in:
parent
09a3976478
commit
25a4699a9e
7
src/db.c
7
src/db.c
@ -697,11 +697,16 @@ void moveCommand(redisClient *c) {
|
|||||||
robj *o;
|
robj *o;
|
||||||
redisDb *src, *dst;
|
redisDb *src, *dst;
|
||||||
int srcid;
|
int srcid;
|
||||||
|
long long dbid;
|
||||||
|
|
||||||
/* Obtain source and target DB pointers */
|
/* Obtain source and target DB pointers */
|
||||||
src = c->db;
|
src = c->db;
|
||||||
srcid = c->db->id;
|
srcid = c->db->id;
|
||||||
if (selectDb(c,atoi(c->argv[2]->ptr)) == REDIS_ERR) {
|
|
||||||
|
if (getLongLongFromObject(c->argv[2],&dbid) == REDIS_ERR ||
|
||||||
|
dbid < INT_MIN || dbid > INT_MAX ||
|
||||||
|
selectDb(c,dbid) == REDIS_ERR)
|
||||||
|
{
|
||||||
addReply(c,shared.outofrangeerr);
|
addReply(c,shared.outofrangeerr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -404,6 +404,12 @@ start_server {tags {"basic"}} {
|
|||||||
r move mykey 10
|
r move mykey 10
|
||||||
} {0}
|
} {0}
|
||||||
|
|
||||||
|
test {MOVE against non-integer DB (#1428)} {
|
||||||
|
r set mykey hello
|
||||||
|
catch {r move mykey notanumber} e
|
||||||
|
set e
|
||||||
|
} {*ERR*index out of range}
|
||||||
|
|
||||||
test {SET/GET keys in different DBs} {
|
test {SET/GET keys in different DBs} {
|
||||||
r set a hello
|
r set a hello
|
||||||
r set b world
|
r set b world
|
||||||
|
Loading…
x
Reference in New Issue
Block a user