Skip to content

host: unsigned-correct range filtering + fix unbounded getComments scan - #18

Merged
0xeb merged 1 commit into
mainfrom
fix/range-unsigned-compare
Jun 23, 2026
Merged

host: unsigned-correct range filtering + fix unbounded getComments scan#18
0xeb merged 1 commit into
mainfrom
fix/range-unsigned-compare

Conversation

@0xeb

@0xeb 0xeb commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Follow-up hardening to the range-end fix (#16).

Unsigned range filtering

The list handlers compared uint64 offsets as signed Java longs and special-cased <= 0, so addresses in the top half of the 64-bit space (≥ INT64_MAX) were mishandled. All 17 handlers now use Long.compareUnsigned, take the range bounds raw (unbounded end = -1), and reset only the exact 0 start sentinel to minAddress (== 0, not <= 0) so a high start is never clobbered. Removes the now-redundant resolveRangeEnd helper.

This is provably a no-op for every address real binaries have (signed and unsigned compare agree on non-negative longs) — verified: /bin/ls and an ELF fixture return identical counts across funcs/names/instructions/strings/xrefs/blocks/data_items/exports/segments.

getComments hang fix

getComments built an AddressSet up to the requested end. After the range-end fix the client sends INT64_MAX, so the set spanned to the top of the space and getCodeUnits walked undefined units across the empty gap — turning SELECT … FROM comments into a multi-second hang/timeout (the table was silently broken; never tested after #7/#16). Clamp the end to the space max and intersect with loaded memory. comments now returns a fast count (55 on /bin/ls).

Also

python/examples/pagination.py: 2**64-12**63-1 for consistency with the C++ examples.

No version bump.

Range-list handlers compared uint64 offsets as signed Java longs and special-
cased <= 0, so addresses in the top half of the 64-bit space (>= INT64_MAX) were
mishandled. Switch all 17 handlers to Long.compareUnsigned, take range bounds
raw (default end = -1 = unbounded), and reset only the exact 0 start sentinel to
minAddress (== 0, not <= 0) so a high start is never clobbered. This is a no-op
for every address real binaries actually have; it removes the now-redundant
resolveRangeEnd helper.

Also fix getComments: it built an AddressSet up to the requested end (now
INT64_MAX for 'all') and walked undefined code units across the empty gap to the
top of the space, hanging 'SELECT ... FROM comments'. Clamp the end to the
space max and intersect with loaded memory.

Also tidy python/examples/pagination.py to INT64_MAX for consistency.
@0xeb
0xeb merged commit 3d83344 into main Jun 23, 2026
16 checks passed
@0xeb
0xeb deleted the fix/range-unsigned-compare branch June 23, 2026 14:48
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.

1 participant