check bfd_alloc/bfd_malloc return in elflink.c

Project / Subsystem

binutils / binutils/bfd

Date

2026-06-13

Proposer

Alan Modra <amodra@gmail.com>

Source type

public_inbox

Consensus

Proposed

Sentiment

/10

All attributes

project
binutils
subsystem
binutils/bfd
patch_id
discussion_id
aiz9Oe59t8FzY7Jx@squeak.grove.modra.org
source_type
public_inbox
title
check bfd_alloc/bfd_malloc return in elflink.c
headline
Adds null checks for memory allocation in elflink.c and replaces sprintf with memcpy for string concatenation
tldr
A patch improves error handling in Binutils' BFD by adding null checks for `bfd_malloc` and `bfd_alloc` calls and optimizes string concatenation using `memcpy`…
proposer
Alan Modra <amodra@gmail.com>
consensus
Proposed
outcome
proposed
sentiment_score
technical_tradeoffs
[]
series_id
series_role
standalone
series_parts
[]
tags
  • binutils
  • bfd
  • elf
  • memory-allocation
  • bugfix
bugzilla_url
date
2026-06-13T00:00:00.000Z

check bfd_alloc/bfd_malloc return in elflink.c

Alan Modra proposes a patch to enhance error handling and efficiency within elflink.c, a core component of Binutils’ BFD library. The primary changes involve adding explicit null checks for memory allocation functions bfd_malloc and bfd_alloc, preventing potential crashes if memory allocation fails. Additionally, the patch replaces sprintf calls with memcpy for concatenating strings, which can offer performance improvements and avoid potential buffer overflows.