Repository navigation
fix: prevent panic during eviction when short dummy entries are encountered - #438
Open
AdamMagued wants to merge 1 commit into
Open
AdamMagued wants to merge 1 commit into
AdamMagued wants to merge 1 commit into
Conversation
…ntered When BytesQueue reallocates memory, it can insert padding/dummy entries (< 18 bytes) into the queue. When isExpired or removeOldestEntry processed these short entries without verifying the length against headersSizeInBytes, a runtime slice bounds panic was triggered. Check entry lengths safely before reading headers in isExpired, removeOldestEntry, and encoding helpers, safely treating short entries as expired so they can be evicted. Fixes allegro#312
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.
When BytesQueue allocates additional memory, it may insert a dummy/padding entry into the queue to fill fragmented space between tail and head. Such dummy entries can have a length shorter than the minimum header size (headersSizeInBytes = 18, e.g. 0 to 17 bytes).
During expiration or eviction in cleanUp, Set, or onEvict, isExpired and removeOldestEntry attempt to decode headers from the entry. Without checking len(oldestEntry) < headersSizeInBytes, slicing or binary decoding triggered a runtime slice bounds out of range panic (runtime error: index out of range [7] with length 0).
Changes:
Fixes #312