Fix command help for unexpected options (#7476)

This commit is contained in:
WuYunlong 2020-07-15 17:38:22 +08:00 committed by GitHub
parent dc690161d5
commit 93bdbf5aa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 3 deletions

View File

@ -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.",

View File

@ -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);

View File

@ -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);

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
}
}