Hi Mark, Sayed,

Following up on the RFC discussion, I have prepared the first small
implementation stage and attached the two patches:

  0001-libdw-Add-checked-initial-length-readers.patch
  0002-libdw-Use-checked-reads-for-DWARF5-initial-lengths.patch

The first patch adds boolean-returning checked 4-byte and 8-byte
incrementing readers. If the complete value is unavailable, the helpers
return false without modifying either the cursor or the result.

The second patch applies these readers to the DWARF32 and DWARF64
initial-length fields in .debug_str_offsets, .debug_rnglists and
.debug_loclists. The existing version, unit-extent and table validation
remains in place.

The series is intentionally limited to this coherent initial-length
family. It also avoids local availability expressions that can form
dataend - 4 or dataend - 8 before establishing that the section contains
that many bytes.

Following Mark's RFC feedback, the core uses boolean-returning static
inline functions and the work is split into two small patches. There are
no public API or ABI changes.

Validation against upstream commit
fb5473ac7368bbbbc2ea9d86241bd6c882e3fcb5:

  - full make check: 253 PASS, 8 SKIP, 0 FAIL
  - focused and parser tests clean under ASan and UBSan
  - 1,610 baseline/patched valid-input comparisons with no differences
  - abidiff reported no ABI differences

Comments and suggestions are welcome.

Thanks,
Karan

Attachment: 0001-libdw-Add-checked-initial-length-readers.patch
Description: Binary data

Attachment: 0002-libdw-Use-checked-reads-for-DWARF5-initial-lengths.patch
Description: Binary data

Reply via email to