Use ufile_ptr for file position

Project / Subsystem

binutils / binutils

Date

2026-07-27

Proposer

Alan Modra <amodra@gmail.com>

Source type

public_inbox

Consensus

Proposed

Sentiment

/10

Technical tradeoffs

  • Fixes a potential integer overflow vulnerability related to large file handling.
  • Improves the safety and correctness of file offset calculations.
  • Removes unnecessary type casts.

All attributes

project
binutils
subsystem
binutils
patch_id
discussion_id
amb5fXXwmsjGAiy2@squeak.grove.modra.org
source_type
public_inbox
title
Use ufile_ptr for file position
headline
Use ufile_ptr for file position
tldr
Changes `file_ptr` to `ufile_ptr` in `elf.c` to safely handle file offsets and removecasts.
proposer
Alan Modra <amodra@gmail.com>
consensus
Proposed
outcome
proposed
sentiment_score
technical_tradeoffs
  • Fixes a potential integer overflow vulnerability related to large file handling.
  • Improves the safety and correctness of file offset calculations.
  • Removes unnecessary type casts.
series_id
series_role
standalone
series_parts
[]
tags
  • binutils
  • bfd
  • elf
  • security
  • fuzzing
bugzilla_url
date
2026-07-27T00:00:00.000Z

Use ufile_ptr for file position

This patch replaces the file_ptr type with ufile_ptr for tracking file offsets within bfd/elf.c. This change directly addresses an issue where file_ptr addition could overflow, as discovered by an objcopy fuzz test. Using an unsigned type (ufile_ptr) for current file offsets provides greater safety and accuracy, allowing for the removal of unnecessary type casts and preventing potential bugs related to large file sizes.