binutils Newspaper
NOVEMBER 30, 2026
ld/pdb — Proposed

ld/pdb: Fix uint16_t overflow in calculate_symbols_size and parse_symbols

Resolves integer overflows and potential infinite loops/crashes in CodeView symbol parsing by using larger integer types and adding bounds checks.

This patch addresses critical integer overflow issues in the ld/pdb.c file, specifically within the calculate_symbols_size and parse_symbols functions responsible for handling CodeView symbol records. The use of uint16_t for symbol record lengths could lead to overflows, causing infinite loops or heap buffer overflows. The fix replaces uint16_t with unsigned int, adjusts loop conditions, and adds necessary bounds checks to prevent these vulnerabilities.

In the Thread 1 participant
  1. Haolin Xue proposer

    Submitted a patch to fix uint16_t overflows in CodeView symbol processing functions, which could lead to infinite loops or buffer overflows.

    “The calculate_symbols_size() and parse_symbols() functions in ld/pdb.c use a uint16_t variable to hold the length of CodeView symbol records: uint16_t len = bfd_getl16 (data) + sizeof (uint16_t); When bfd_getl16() returns 0xFFFE, the addition produces 0x10000, which truncates to 0 when stored in uint16_t. This causes the loop to stall (data += 0, size -= 0) resulting in an infinite loop.”

In Details

This patch targets ld/pdb.c to fix vulnerabilities related to parsing CodeView debug information. The functions calculate_symbols_size and parse_symbols incorrectly use uint16_t to store symbol record lengths derived from bfd_getl16. When bfd_getl16 returns 0xFFFE, the subsequent addition with sizeof(uint16_t) results in 0x10000, which truncates to 0 in uint16_t. This leads to infinite loops in calculate_symbols_size and a defeated bounds check in parse_symbols. Additionally, parse_symbols reads 4 bytes after a while (size >= sizeof(uint16_t)) condition, potentia…

For Context
ld/pdb.c
A source file within the binutils project that handles the parsing and manipulation of CodeView debug information for PDB (Program Database) files, commonly used by Microsoft compilers.
CodeView
A de-facto standard debug information format developed by Microsoft, used by their compilers and linkers.
uint16_t
An unsigned integer type that occupies exactly 16 bits. Its maximum value is 65,535.
bfd_getl16
A function from the Binary File Descriptor (BFD) library that reads a 16-bit unsigned integer in little-endian format from a data stream.
integer overflow
A condition that occurs when an arithmetic operation produces a result that is too large to be represented within the allocated number of bits for the data type.
heap buffer overflow
A vulnerability that occurs when a program writes data beyond the allocated buffer in the heap memory, potentially corrupting adjacent memory and leading to crashes or security exploits.
Filed Under: binutilsldpdbbugfixsecurity