binutils Newspaper
NOVEMBER 30, 2026
xcoff — Proposed

xcoff: Check loader header size before reading

Add a size check to prevent out-of-bounds reads when parsing malformed XCOFF files.

This patch addresses a memory-safety issue in the XCOFF parser where malformed files with undersized .loader sections could lead to out-of-bounds reads. The fix adds a check to ensure the section is large enough before attempting to parse the loader header, preventing heap-buffer-overflows reported by AddressSanitizer.

In the Thread 1 participant
  1. Alhuda Khan <alhuda@research.digiscrypt.com> proposer

    Proposes adding a size check for the .loader section to prevent out-of-bounds reads in `xcoff_get_ldhdr()` when parsing malformed XCOFF files.

    “Reject the section when it is smaller than bfd_xcoff_ldhdrsz (abfd) before swapping in the header. After the change the malformed file is reported as "file truncated" and a valid XCOFF object still parses correctly.”

In Details

The xcoff_get_ldhdr function in binutils' XCOFF BFD module parses the loader header from the .loader section. A malformed XCOFF can have a .loader section smaller than expected, causing bfd_getb32 to read past the allocated buffer during bfd_xcoff_swap_ldhdr_in. This patch adds a size check against bfd_xcoff_ldhdrsz to prevent this overflow.

Filed Under: memory-safetyxcoffbinutilsobjdumpsecurity