Skip to content

Fix range-filtered tables returning 0 rows (#2, #3, #6) - #7

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

Fix range-filtered tables returning 0 rows (#2, #3, #6)#7
0xeb merged 1 commit into
mainfrom
fix/range-end-sentinel

Conversation

@0xeb

@0xeb 0xeb commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Problem

Range-filtered tables (funcs, names, instructions, strings, xrefs, blocks, imports, exports, …) return 0 rows for many programs, while non-range tables (segments, types) and address-specific calls (decompile(addr), UPDATE … WHERE address=X) work. Reported in #2 (with correct root-cause), #3, and #6.

Root cause

The client sends the range upper bound as kAllAddressesMax = UINT64_MAX. The LibGhidraHost decodes the protobuf uint64 into a signed Java long = -1, then falls back to program.getMaxAddress().getOffset(). For programs whose max address sits in a low-offset space (an EXTERNAL block, or file-backed "OTHER" sections at offset 0), the scan window collapses and the iterator breaks on the first real function → 0 rows. Programs without that layout (e.g. Mach-O /bin/ls) work by luck.

Fix

Use INT64_MAX (0x7FFFFFFFFFFFFFFF) so the sentinel stays positive on the host; the broken <= 0 fallback never fires and the window includes every real address. One constant flows to all ~20 List* call sites. Works against existing LibGhidraHost installs (no extension reinstall needed). Also drops two unused includes.

The host-side companion hardening is 0xeb/libghidra#16 (either fix alone is sufficient).

Verification

Built a small Linux ELF (5 funcs, EXTERNAL refs) that triggers the bug:

table before after
funcs 0 9
names 0 15
instructions 0 77
xrefs 0 50

/bin/ls regression unchanged (136 funcs). Addresses #2, #3, #6.

The LibGhidraHost decodes the protobuf uint64 range-end into a signed Java
long, so the kAllAddressesMax=UINT64_MAX sentinel arrived as -1 and tripped a
getMaxAddress() fallback that emptied funcs/names/instructions/strings/xrefs/etc.
for programs whose max address sits in a low-offset space (EXTERNAL block or
file-backed sections). Use INT64_MAX so the sentinel stays positive on the host.

Also drop two unused includes.
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