[PATCH] binutils: validate DW_LNE_define_file filename bounds

Alhuda Khan alhuda@research.digiscrypt.com
Sun Nov 22 10:35:35 GMT 2026


Hi,

readelf -wL can read past the end of the .debug_line buffer on a malformed
DWARF line program. In display_debug_lines_decoded(), the DW_LNE_define_file
opcode reads the file name with an unbounded strlen() on op_code_data. If the
name has no terminating NUL before the end of the opcode payload - which can
happen once the section is decompressed into an exact-size heap allocation -
strlen() runs off the end of the buffer, which ASan reports as a
heap-buffer-overflow.

The patch is attached. It uses memchr() bounded by op_code_end to find the
terminator, and if there isn't one it warns and stops processing that opcode
instead of walking past the end.

Thanks,
Alhuda Khan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-binutils-validate-DW_LNE_define_file-filename-bounds.patch
Type: application/octet-stream
Size: 2264 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20261122/99141e36/attachment.obj>


More information about the Binutils mailing list