diff options
author | Binbin <binloveplay1314@qq.com> | 2022-01-09 19:06:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-09 13:06:51 +0200 |
commit | a84c964d37a1899bf90c920efef85a1d7202d058 (patch) | |
tree | 47c816699b2764987bc92677adf3be90ce3422ff /src/config.c | |
parent | 75c50a15633881bb2bf0455bdabcbbabc0e47044 (diff) | |
download | redis-a84c964d37a1899bf90c920efef85a1d7202d058.tar.gz |
Fix crash when error [sub]command name contains | (#10082)
The following error commands will crash redis-server:
```
> get|
Error: Server closed the connection
> get|set
Error: Server closed the connection
> get|other
```
The reason is in #9504, we use `lookupCommandBySds` for find the
container command. And it split the command (argv[0]) with `|`.
If we input something like `get|other`, after the split, `get`
will become a valid command name, pass the `ERR unknown command`
check, and finally crash in `addReplySubcommandSyntaxError`
In this case we do not need to split the command name with `|`
and just look in the commands dict to find if `argv[0]` is a
container command.
So this commit introduce a new function call `isContainerCommandBySds`
that it will return true if a command name is a container command.
Also with the old code, there is a incorrect error message:
```
> config|get set
(error) ERR Unknown subcommand or wrong number of arguments for 'set'. Try CONFIG|GET HELP.
```
The crash was reported in #10070.
Diffstat (limited to 'src/config.c')
0 files changed, 0 insertions, 0 deletions