Skip to content

Reject H3 index strings that overflow 64 bits - #238

Open
kwy404 wants to merge 1 commit into
uber:masterfrom
kwy404:fix-oversized-h3-index-string
Open

kwy404 wants to merge 1 commit into
uber:masterfrom
kwy404:fix-oversized-h3-index-string

Conversation

@kwy404

@kwy404 kwy404 commented Sep 24, 2026

Copy link
Copy Markdown

h3IndexToSplitLong parses everything except the last 8 hex characters as the upper 32 bits, but it never checked that the result fits. For a string longer than 16 characters the upper value goes past 2^32 and is truncated when passed to the C library, so extra leading digits are silently dropped. For example, isValidCell('1085283473fffffff') returns true, and cellToLatLng returns the location of 85283473fffffff.

This returns [0, 0] (like other invalid strings) when the upper part does not fit in 32 bits, so strings with leading zeros are still accepted. I added an isValidCell assertion that fails before the change, plus a changelog entry. yarn test-raw and yarn lint pass.

h3IndexToSplitLong parsed everything before the last 8 hex chars as the
upper word, so a string longer than 16 chars produced an upper value above
32 bits that was then truncated when passed to C. Extra leading digits
were silently dropped and, for example, isValidCell('1085283473fffffff')
returned true.
@CLAassistant

CLAassistant commented Sep 24, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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