Skip to content

Fix potential integer overflow in buffer growth logic - #2

Closed
mohammidharaz wants to merge 1 commit into
harden-realloc-overflowfrom
harden-realloc-real
Closed

Fix potential integer overflow in buffer growth logic#2
mohammidharaz wants to merge 1 commit into
harden-realloc-overflowfrom
harden-realloc-real

Conversation

@mohammidharaz

Copy link
Copy Markdown
Owner

This patch hardens buffer growth logic in yaml_string_extend,
yaml_stack_extend, and yaml_queue_extend by adding a SIZE_MAX guard
before doubling allocation sizes.

Without this check, integer overflow could occur when calculating
the new buffer size, potentially resulting in incorrect memory
allocation and memory corruption.

The patch preserves existing behavior while preventing overflow
during realloc size calculations.

Add SIZE_MAX guard before doubling buffer sizes in
yaml_string_extend, yaml_stack_extend, and yaml_queue_extend.
Prevents overflow during realloc size calculation.
@mohammidharaz
mohammidharaz deleted the harden-realloc-real branch February 25, 2026 13:09
@mohammidharaz
mohammidharaz restored the harden-realloc-real branch February 25, 2026 13:10

@mohammidharaz mohammidharaz left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

.

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.

1 participant