Skip to content

Fix memcpy of id from key to be slightly safer.#6645

Merged
antirez merged 1 commit intoredis:unstablefrom
eliblight:fix-memcpy
Dec 5, 2019
Merged

Fix memcpy of id from key to be slightly safer.#6645
antirez merged 1 commit intoredis:unstablefrom
eliblight:fix-memcpy

Conversation

@eliblight
Copy link
Contributor

The memcpy from the key to the id relies on the fact that this key
should be 8 bytes long as it was entered as such a few lines up the
code.

BUT if someone will change the code to the point this is no longer true,
current code can trash the stack which makes debugging very hard
while this fix will result in some garbage id, or even page fault.
Both are preferable to stack mangaling.

+        memcpy(&id,ri.key,sizeof(id));

The memcpy from the key to the id reliease on the fact that this key
*should* be 8 bytes long as it was entered as such a few lines up the
code.

BUT if someone will change the code to the point this is no longer true,
current code can trash the stack which makes debugging very hard
while this fix will result in some garbage id, or even page fault.
Both are preferable to stack mangaling.
@antirez antirez merged commit 7e24e21 into redis:unstable Dec 5, 2019
@antirez
Copy link
Contributor

antirez commented Dec 5, 2019

Thanks @eliblight, merged.

@eliblight eliblight deleted the fix-memcpy branch December 5, 2019 16:01
JackieXie168 pushed a commit to JackieXie168/redis that referenced this pull request Dec 24, 2019
Fix memcpy of id from key to be slightly safer.
oshadmi added a commit to oshadmi/redis that referenced this pull request Sep 28, 2025
$ gitlog v8.2.1..v8.2.5

redis#6867 Improve BUILD_INTEL_SVS_OPT flag validation
redis#6845 Fix vector compression type reporting and rename SVS environment variable
redis#6794 Fix rpcountFree casting
redis#6825 Bump vecsim 8.2.4
redis#6787 Fix deadlock while RDB loading and RM_Yield (redis#6763)
redis#6723 Fix ACLUserMayAccessIndex
redis#6701 Fix fd leak when OOM
redis#6676 bump svs version
redis#6671 Add SVS-VAMANA index to info fields telemetry
redis#6665 Optimize rs_wall_clock_diff_ns by removing redundant if branch
redis#6641 Update vectors memory in total index info memory
redis#6634 Log DocTable capacity growth for memory diagnostics
redis#6649 Bump minimal redis version
redis#6648 Fix "has map" performance
redis#6645 Trie: hide expensive memory usage computation behind a test-specific feature flag.
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.

2 participants