Repository navigation
gridRing: validate k before wiping the output array - #1235
Merged
Merged
Conversation
isaacbrodsky
approved these changes
Sep 7, 2026
isaacbrodsky
requested review from
ajfriend,
dfellis,
dmitryzv,
jongbinjung and
nrabinowitz
September 7, 2026 01:02
gridRing wiped the caller's array with a width of 6 * k before any domain check ran, so a negative k became a size_t of about 1.8e19 and the memset ran off the end of the buffer (AddressSanitizer: negative-size-param, size=-48). The width now comes from maxGridRingSize, which rejects a negative k with E_DOMAIN and computes the size in int64_t. Every k the function previously handled wipes the same width as before.
lenamonj
force-pushed
the
gridring-negative-k
branch
from
September 13, 2026 17:46
6c2bffb to
6fc7b6d
Compare
Contributor
Author
|
Anything else needed from me here? It has been approved and green since the 7th. |
justinhwang
approved these changes
Oct 1, 2026
1 task
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.
gridRingwiped the caller's output array withmemset(out, 0, 6 * k * sizeof(H3Index))before any domain check ran, so a negativekbecame asize_tof about 1.8e19 and the write ran off the end of the buffer. AddressSanitizer ongridRing(origin, -1, out):negative-size-param: (size=-48). Callers sawE_DOMAINonly if the process survived the write.The width now comes from
maxGridRingSize, which rejects a negativekwithE_DOMAINbefore the wipe and computes the size inint64_t. Everykthe function previously handled wipes the same width as before. The new test uses a heap buffer so the old write faults under ASan; it passes with the fix.