summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWuYunlong <xzsyeb@126.com>2020-07-15 17:38:22 +0800
committerGitHub <noreply@github.com>2020-07-15 12:38:22 +0300
commit93bdbf5aa4857ede0816cf790f951da8e2fa2ae9 (patch)
tree17c4bdf0ed8123b46bf52782145e4733542662de
parentdc690161d5652d86d51bd209821bfb0e9c5f7ec2 (diff)
downloadredis-93bdbf5aa4857ede0816cf790f951da8e2fa2ae9.tar.gz
Fix command help for unexpected options (#7476)
-rw-r--r--src/acl.c2
-rw-r--r--src/latency.c2
-rw-r--r--src/t_stream.c2
-rw-r--r--tests/unit/acl.tcl5
-rw-r--r--tests/unit/latency-monitor.tcl5
-rw-r--r--tests/unit/type/stream.tcl7
6 files changed, 20 insertions, 3 deletions
diff --git a/src/acl.c b/src/acl.c
index 6dd0f70ac..3ce45f03b 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -1911,7 +1911,7 @@ void aclCommand(client *c) {
addReplyBulkCString(c,"client-info");
addReplyBulkCBuffer(c,le->cinfo,sdslen(le->cinfo));
}
- } else if (!strcasecmp(sub,"help")) {
+ } else if (c->argc == 2 && !strcasecmp(sub,"help")) {
const char *help[] = {
"LOAD -- Reload users from the ACL file.",
"SAVE -- Save the current config to the ACL file.",
diff --git a/src/latency.c b/src/latency.c
index 9a291ac9b..dfdc6668c 100644
--- a/src/latency.c
+++ b/src/latency.c
@@ -621,7 +621,7 @@ NULL
resets += latencyResetEvent(c->argv[j]->ptr);
addReplyLongLong(c,resets);
}
- } else if (!strcasecmp(c->argv[1]->ptr,"help") && c->argc >= 2) {
+ } else if (!strcasecmp(c->argv[1]->ptr,"help") && c->argc == 2) {
addReplyHelp(c, help);
} else {
addReplySubcommandSyntaxError(c);
diff --git a/src/t_stream.c b/src/t_stream.c
index 676ddd9bb..f564b1ff9 100644
--- a/src/t_stream.c
+++ b/src/t_stream.c
@@ -1885,7 +1885,7 @@ NULL
server.dirty++;
notifyKeyspaceEvent(NOTIFY_STREAM,"xgroup-delconsumer",
c->argv[2],c->db->id);
- } else if (!strcasecmp(opt,"HELP")) {
+ } else if (c->argc == 2 && !strcasecmp(opt,"HELP")) {
addReplyHelp(c, help);
} else {
addReplySubcommandSyntaxError(c);
diff --git a/tests/unit/acl.tcl b/tests/unit/acl.tcl
index 85c9b81a9..e81280995 100644
--- a/tests/unit/acl.tcl
+++ b/tests/unit/acl.tcl
@@ -255,4 +255,9 @@ start_server {tags {"acl"}} {
r ACL setuser default on
set e
} {*NOAUTH*}
+
+ test {ACL HELP should not have unexpected options} {
+ catch {r ACL help xxx} e
+ assert_match "*Unknown subcommand or wrong number of arguments*" $e
+ }
}
diff --git a/tests/unit/latency-monitor.tcl b/tests/unit/latency-monitor.tcl
index d76867cc6..18b9ecebb 100644
--- a/tests/unit/latency-monitor.tcl
+++ b/tests/unit/latency-monitor.tcl
@@ -67,4 +67,9 @@ start_server {tags {"latency-monitor"}} {
}
assert_match {*expire-cycle*} [r latency latest]
}
+
+ test {LATENCY HELP should not have unexpected options} {
+ catch {r LATENCY help xxx} e
+ assert_match "*Unknown subcommand or wrong number of arguments*" $e
+ }
}
diff --git a/tests/unit/type/stream.tcl b/tests/unit/type/stream.tcl
index c2b524d7f..0ff570cab 100644
--- a/tests/unit/type/stream.tcl
+++ b/tests/unit/type/stream.tcl
@@ -461,3 +461,10 @@ start_server {tags {"stream"} overrides {appendonly yes aof-use-rdb-preamble no}
assert {[dict get [r xinfo stream mystream] last-generated-id] == "2-2"}
}
}
+
+start_server {tags {"stream"}} {
+ test {XGROUP HELP should not have unexpected options} {
+ catch {r XGROUP help xxx} e
+ assert_match "*Unknown subcommand or wrong number of arguments*" $e
+ }
+}