Skip to content

fix: replace sprintf with safe_snprintf in SBS output - #301

Open
zagers wants to merge 1 commit into
flightaware:masterfrom
zagers:fix/sbs-buffer-overflow
Open

fix: replace sprintf with safe_snprintf in SBS output#301
zagers wants to merge 1 commit into
flightaware:masterfrom
zagers:fix/sbs-buffer-overflow

Conversation

@zagers

@zagers zagers commented Jul 18, 2026

Copy link
Copy Markdown

Summary

Replaces all unbounded sprintf calls with safe_snprintf in the SBS output function to prevent potential buffer overflow.

Changes

  • net_io.c: In send_sbs_message(), replaced 20+ sprintf calls with safe_snprintf(p, end, ...) which respects the buffer boundary
  • Wrapped the function body in a block to scope the end pointer computed from the 200-byte buffer allocation

Motivation

The SBS output function prepared a 200-byte buffer via prepareWrite() but used sprintf which has no bounds checking. While the SBS message format is relatively fixed-length, safe_snprintf is the pattern used throughout the rest of the codebase and provides defense-in-depth against unexpected field lengths.

Fixes #297

The SBS output function used unbounded sprintf into a fixed 200-byte
buffer. Replace all sprintf calls with safe_snprintf which respects
the buffer end pointer, preventing potential buffer overflow.

Fixes flightaware#297
@mutability mutability added the LLM has LLM-generated content, treat with extreme suspicion label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LLM has LLM-generated content, treat with extreme suspicion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Buffer overflow in SBS output via unbounded sprintf

2 participants