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

Use ufile_ptr for file position

Replaces `file_ptr` with `ufile_ptr` for file offsets in ELF processing to prevent overflow issues.

This commit changes the type used for file positions in BFD’s ELF processing from file_ptr to ufile_ptr. This change, motivated by a fuzzing test that revealed an overflow in file_ptr addition, correctly uses an unsigned type for offsets. It also allows for the removal of a couple of casts.

In Details

In bfd/elf.c, the file_ptr type, which is an alias for long, is replaced by ufile_ptr (an alias for unsigned long) for file offsets. This change addresses an overflow vulnerability identified through fuzzing, where additions to file_ptr could exceed its maximum value. By using ufile_ptr, the code now correctly handles potentially large file offsets, and some explicit casts become unnecessary.

For Context
bfd
Binary File Descriptor library. This library provides a common interface for accessing various executable file formats, including reading symbol tables and debugging information.
ELF
Executable and Linkable Format. A common standard file format for executable, object code, shared libraries, and core dumps, used widely on Unix-like systems.
file_ptr
A data type, likely an alias for long, used to represent file offsets or positions within a file. Its signed nature can lead to issues with very large files.
ufile_ptr
An unsigned data type, likely an alias for unsigned long, used to represent file offsets or positions. Using an unsigned type avoids issues with negative values and allows for larger positive offset values compared to signed types.
fuzzing
A software testing technique that involves providing invalid, unexpected, or random data as input to a program to find bugs, crashes, or security vulnerabilities.
objcopy
A utility that can modify object files. It can be used for tasks like stripping symbols, changing endianness, or altering file formats.
Filed Under: elfsecuritybugfix