Skip to content

FWBUG-1471 frame.c: frame_hdrs_get returns -1 as size_t on allocation…#6

Merged
cj-linas-nenorta merged 1 commit into
cujofrom
sampsa/fwbug-1471_frame_hdrs_get_returns_minus1
Jul 17, 2026
Merged

FWBUG-1471 frame.c: frame_hdrs_get returns -1 as size_t on allocation…#6
cj-linas-nenorta merged 1 commit into
cujofrom
sampsa/fwbug-1471_frame_hdrs_get_returns_minus1

Conversation

@cj-sampsa-ranta

Copy link
Copy Markdown

… failure

Description: Return type is size_t (unsigned) but the function returns -1 on realloc failure, which becomes SIZE_MAX. Callers iterating over headers will read far out of bounds.
Recommendation: Change return type to ssize_t, or return 0 with *hdrs = NULL on failure.

Following the recommended solution from ticket.

… failure

Description: Return type is `size_t` (unsigned) but the function returns `-1` on realloc failure, which becomes `SIZE_MAX`. Callers iterating over headers will read far out of bounds.
Recommendation: Change return type to `ssize_t`, or return `0` with `*hdrs = NULL` on failure.

Following the recommended solution from ticket.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Addresses FWBUG-1471 by fixing an error-path contract bug in frame_hdrs_get() where returning -1 from a size_t function could become SIZE_MAX, causing callers iterating headers to read out of bounds.

Changes:

  • On stomp_realloc() failure in frame_hdrs_get(), return 0 and set *hdrs = NULL instead of returning -1 (as size_t).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/frame.c
Comment thread src/frame.c

@cj-linas-nenorta cj-linas-nenorta left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cj-linas-nenorta
cj-linas-nenorta merged commit 4da23e1 into cujo Jul 17, 2026
2 checks passed
@cj-linas-nenorta
cj-linas-nenorta deleted the sampsa/fwbug-1471_frame_hdrs_get_returns_minus1 branch July 17, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants