From c98a28a8480feeb00ccca80d23fcbe6d1718f6ed Mon Sep 17 00:00:00 2001 From: Binbin Date: Mon, 21 Aug 2023 17:50:41 +0800 Subject: [PATCH] Fix LREM count LONG_MIN overflow minor issue (#12465) Limit the range of LREM count to -LONG_MAX ~ LONG_MAX. Before the fix, passing -LONG_MAX would cause an overflow and would effectively be the same as passing 0. (Because this condition `toremove && removed == toremove `can never be satisfied). This is a minor fix as it shouldn't really affect users, more like a cleanup. --- src/t_list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t_list.c b/src/t_list.c index dc16606c9..8da0a21c4 100644 --- a/src/t_list.c +++ b/src/t_list.c @@ -1060,7 +1060,7 @@ void lremCommand(client *c) { long toremove; long removed = 0; - if ((getLongFromObjectOrReply(c, c->argv[2], &toremove, NULL) != C_OK)) + if (getRangeLongFromObjectOrReply(c, c->argv[2], -LONG_MAX, LONG_MAX, &toremove, NULL) != C_OK) return; subject = lookupKeyWriteOrReply(c,c->argv[1],shared.czero);