Fix missing kvobj reassignment after reallocation in MOVE command#14233
Merged
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a critical bug in the MOVE command that caused crashes when moving hash objects with both key and field expiration. The crash occurred due to a missing kvobj pointer update after potential reallocation during expiration setting.
- Fixed missing kvobj reassignment after
setExpireByLink()call in MOVE command - Added test case to reproduce the bug scenario with forced kvobj reallocation
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/db.c | Updated MOVE command to capture returned kvobj from setExpireByLink() to prevent use-after-free |
| tests/unit/type/hash-field-expire.tcl | Added test case with key expiration to force kvobj reallocation during MOVE |
moticless
approved these changes
Jul 30, 2025
|
New Issues (8)Checkmarx found the following issues in this Pull Request
Fixed Issues (5)Great job! The following issues were fixed in this Pull Request
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Introduced by #13806
Fixed a crash in the MOVE command when moving hash objects that have both key expiration and field expiration.
The issue occurred in the following scenario:
setExpireByLink()is called to set the expiration time for the target hash, which may reallocate the kvobj of hash.hashTypeAddToExpires()is called to update the minimum field expiration timeIssue:
However, the kvobj pointer wasn't updated with the return value from
setExpireByLink(), causinghashTypeAddToExpires()to use freed memory.report from the test (build with SANITIZER address):