binutils Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
binutils/bfd

PR 34418 alpha_vms_slurp_relocs off-by-one section index check

Fixed an off-by-one error in BFD's VMS Alpha relocation handling by correcting section index bounds checking.

Corrected an off-by-one error in the alpha_vms_slurp_relocs function within BFD, which handles VMS Alpha relocations. The fix involves making the cur_psect variable unsigned and adjusting the bounds check to prevent incorrect section indexing, resolving a potential issue where invalid section indices could be accepted.

In Details

The alpha_vms_slurp_relocs function in bfd/vms-alpha.c previously had an off-by-one error in its section index checking. By changing cur_psect to an unsigned integer (unsigned int) and initializing it to -1u, and then changing the bounds check from cur_psect < 0 || cur_psect > (int)PRIV (section_count) to cur_psect >= PRIV (section_count), the check now correctly prevents out-of-bounds access to the section data, ensuring relocation processing is safe.

For Context
BFd
The Binary File Descriptor library, a low-level library used by binutils and GDB to read and write object files in various formats.
VMS
Virtual Memory System. An operating system originally developed by Digital Equipment Corporation (DEC) for their VAX and Alpha computer systems.
Alpha
A 64-bit Reduced Instruction Set Computer (RISC) microarchitecture developed by Digital Equipment Corporation (DEC), later continued by Compaq and HP.
relocations
Information in an object file that tells the linker how to modify certain parts of the code or data (e.g., addresses) when linking it with other files or loading it into memory.
section index
An identifier for a specific section (e.g., code, data, BSS) within an object file.
off-by-one error
A common programming error where a loop or conditional check iterates one time too many or too few, or accesses an array element just outside its valid bounds.
Filed Under: binutilsbfdalphavmsbugfix