Skip to content

fix(zset): reject non-positive numkeys in ZUNIONSTORE, ZINTERSTORE and ZDIFFSTORE - #3738

Open
Anurag-S1ngh wants to merge 2 commits into
apache:unstablefrom
Anurag-S1ngh:fix/3729-zset-store-numkeys
Open

Anurag-S1ngh wants to merge 2 commits into
apache:unstablefrom
Anurag-S1ngh:fix/3729-zset-store-numkeys

Conversation

@Anurag-S1ngh

Copy link
Copy Markdown

Summary

ZUNIONSTORE, ZINTERSTORE and ZDIFFSTORE accepted numkeys 0 and left the key list empty. ZSet::Diff and ZSet::Inter then read keys[0], crashing the server with a SIGSEGV.

Changes

  • Reject non-positive numkeys in CommandZUnionStore::Parse and CommandZDiffStore::Parse with value is out of range, must be positive, matching ZDIFF and ZINTER.

Testing

  • Added a regression test in tests/gocase/unit/type/zset covering 0 and -1 for all three commands and asserting no destination key is written.
  • ./x.py test go build -run TestZSet passes.
  • clang-format clean, golangci-lint reports 0 issues.

Closes #3729

…d ZDIFFSTORE

The store variants accepted numkeys 0 and left the key list empty, so
ZSet::Diff and ZSet::Inter read keys[0] and crashed the server. Reject
non-positive numkeys in both parsers, matching ZDIFF and ZINTER.
@github-actions

Copy link
Copy Markdown

Hi @Anurag-S1ngh,

Thank you for your pull request. Please review our Contributing Guide.

Please make sure you understand your changes and explain your reasoning in this pull request. Low-quality pull requests may be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ZDIFFSTORE and ZINTERSTORE with numkeys 0 crash the server (SIGSEGV)

1 participant