Incorrect arg count results in panic
Opened this issue · 0 comments
yob commented
If I leave off an arg of any command (like SET
):
$ redis-cli set
.. then the server panics:
2020/10/25 13:12:45 Database connection open with 25 max connections
2020/10/25 13:12:45 pgredis started on 0.0.0.0:6379
panic: runtime error: slice bounds out of range [:2] with capacity 1
goroutine 11 [running]:
github.com/yob/pgredis.(*setCommand).keysToLock(0xa43328, 0xc00000ece0, 0xc0000ae043, 0x3, 0xc0002302c8)
/work/cmd_strings.go:395 +0x6b
github.com/yob/pgredis.(*PgRedis).executeSingleCommand(0xc00006a2d0, 0xc000076ab0, 0x1, 0x2, 0x1, 0xc00001c340, 0x0)
/work/pgredis.go:289 +0x2f5
github.com/yob/pgredis.(*PgRedis).handleConnection(0xc00006a2d0, 0x83efa0, 0xc000010078)
/work/pgredis.go:242 +0x696
created by github.com/yob/pgredis.(*PgRedis).StartServer
/work/pgredis.go:161 +0x335
Maybe each command object should know the minimum number of args for that command, and we can return an error to the client when the minimum isn't emet