This is an automated email from the ASF dual-hosted git repository.
twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 31bcd8a6 Fix ZRANGESTORE arity -4 that crashes the server (#1593)
31bcd8a6 is described below
commit 31bcd8a62f2faf097a8558e97cea7fc085a08f11
Author: Binbin <[email protected]>
AuthorDate: Fri Jul 14 16:30:45 2023 +0800
Fix ZRANGESTORE arity -4 that crashes the server (#1593)
ZRANGESTORE arity should be -5, the code wrongtly sets it to -4,
when passing 4 arguments, server will trigger a Segmentation fault
and result a crash:
```
127.0.0.1:6666> zrangestore dstzset srczset 0
Error: Server closed the connection
not connected>
```
---
src/commands/cmd_zset.cc | 2 +-
tests/gocase/unit/type/zset/zset_test.go | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/commands/cmd_zset.cc b/src/commands/cmd_zset.cc
index 1b76974a..88a8d80d 100644
--- a/src/commands/cmd_zset.cc
+++ b/src/commands/cmd_zset.cc
@@ -1355,7 +1355,7 @@ REDIS_REGISTER_COMMANDS(MakeCmdAttr<CommandZAdd>("zadd",
-4, "write", 1, 1, 1),
MakeCmdAttr<CommandBZPopMin>("bzpopmin", -3, "write",
1, -2, 1),
MakeCmdAttr<CommandZMPop>("zmpop", -4, "write",
CommandZMPop::Range),
MakeCmdAttr<CommandBZMPop>("bzmpop", -5, "write",
CommandBZMPop::Range),
- MakeCmdAttr<CommandZRangeStore>("zrangestore", -4,
"write", 1, 1, 1),
+ MakeCmdAttr<CommandZRangeStore>("zrangestore", -5,
"write", 1, 1, 1),
MakeCmdAttr<CommandZRange>("zrange", -4, "read-only",
1, 1, 1),
MakeCmdAttr<CommandZRevRange>("zrevrange", -4,
"read-only", 1, 1, 1),
MakeCmdAttr<CommandZRangeByLex>("zrangebylex", -4,
"read-only", 1, 1, 1),
diff --git a/tests/gocase/unit/type/zset/zset_test.go
b/tests/gocase/unit/type/zset/zset_test.go
index e3d38f08..847cb576 100644
--- a/tests/gocase/unit/type/zset/zset_test.go
+++ b/tests/gocase/unit/type/zset/zset_test.go
@@ -454,6 +454,14 @@ func basicTests(t *testing.T, rdb *redis.Client, ctx
context.Context, encoding s
util.ErrorRegexp(t, rdb.Do(ctx, "bzmpop", 0.1, 1, "zseta",
"min", "count", 1, "count", 10).Err(), ".*syntax error.*")
})
+ t.Run(fmt.Sprintf("ZRANGESTORE arity check - %s", encoding), func(t
*testing.T) {
+ rdb.Del(ctx, "zsrc")
+ rdb.Del(ctx, "zdst")
+
+ util.ErrorRegexp(t, rdb.Do(ctx, "zrangestore", "zdst",
"zsrc").Err(), ".*wrong number of arguments.*")
+ util.ErrorRegexp(t, rdb.Do(ctx, "zrangestore", "zdst", "zsrc",
0).Err(), ".*wrong number of arguments.*")
+ })
+
t.Run(fmt.Sprintf("ZRANGESTORE basics - %s", encoding), func(t
*testing.T) {
rdb.Del(ctx, "zsrc")
rdb.Del(ctx, "zdst")