fix: reject zset variadic commands with 0 keys (#2022)

Fixes the assertion failure as reported by #1994.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2023-10-15 14:34:04 +03:00 committed by GitHub
parent 826b1d81a3
commit bcfd1863c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 11 deletions

View file

@ -1462,12 +1462,10 @@ OpResult<KeyIndex> DetermineKeys(const CommandId* cid, CmdArgList args) {
if (!absl::SimpleAtoi(num, &num_custom_keys) || num_custom_keys < 0)
return OpStatus::INVALID_INT;
if (name == "ZDIFF" && num_custom_keys == 0) {
return OpStatus::INVALID_INT;
}
if (name == "ZUNION" && num_custom_keys == 0) {
return OpStatus::SYNTAX_ERR;
if (num_custom_keys == 0 &&
(absl::StartsWith(name, "ZDIFF") || absl::StartsWith(name, "ZUNION") ||
absl::StartsWith(name, "ZINTER"))) {
return OpStatus::AT_LEAST_ONE_KEY;
}
if (args.size() < size_t(num_custom_keys) + num_keys_index + 1)