summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Chen <QuChen88@users.noreply.github.com>2021-02-28 21:54:52 -0800
committerGitHub <noreply@github.com>2021-03-01 07:54:52 +0200
commita66814fd7ac2b37cefb43f2ec03dd8684ebcccf2 (patch)
tree3a0e9ef2004b6e91ed9fc4eb3654b4cf494e581f
parent18ff8cd1fbe0d4c4bc6d090ef58a513ecb9767da (diff)
downloadredis-a66814fd7ac2b37cefb43f2ec03dd8684ebcccf2.tar.gz
Make dbid range check for SWAPDB command consistent with SELECT, MOVE, and COPY. (#8555)
DB ID used to be parsed as a long for SWAPDB command, now make it into an int to be consistent with other commands that parses the DB ID argument like SELECT, MOVE, COPY. See #8085 The implication is that the error message when the provided db index is greater than 4M changes slightly.
-rw-r--r--src/db.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/db.c b/src/db.c
index ed522401f..57705f003 100644
--- a/src/db.c
+++ b/src/db.c
@@ -1315,7 +1315,7 @@ void scanDatabaseForReadyLists(redisDb *db) {
*
* Returns C_ERR if at least one of the DB ids are out of range, otherwise
* C_OK is returned. */
-int dbSwapDatabases(long id1, long id2) {
+int dbSwapDatabases(int id1, int id2) {
if (id1 < 0 || id1 >= server.dbnum ||
id2 < 0 || id2 >= server.dbnum) return C_ERR;
if (id1 == id2) return C_OK;
@@ -1356,7 +1356,7 @@ int dbSwapDatabases(long id1, long id2) {
/* SWAPDB db1 db2 */
void swapdbCommand(client *c) {
- long id1, id2;
+ int id1, id2;
/* Not allowed in cluster mode: we have just DB 0 there. */
if (server.cluster_enabled) {
@@ -1365,11 +1365,11 @@ void swapdbCommand(client *c) {
}
/* Get the two DBs indexes. */
- if (getLongFromObjectOrReply(c, c->argv[1], &id1,
+ if (getIntFromObjectOrReply(c, c->argv[1], &id1,
"invalid first DB index") != C_OK)
return;
- if (getLongFromObjectOrReply(c, c->argv[2], &id2,
+ if (getIntFromObjectOrReply(c, c->argv[2], &id2,
"invalid second DB index") != C_OK)
return;