Skip to content

[57_maintenance] Prevent buffer builder length overflow in MutableBuffer::extend_zeros (#9820)#9926

Merged
alamb merged 1 commit intoapache:57_maintenancefrom
alamb:alamb/backport_9820_57
May 6, 2026
Merged

[57_maintenance] Prevent buffer builder length overflow in MutableBuffer::extend_zeros (#9820)#9926
alamb merged 1 commit intoapache:57_maintenancefrom
alamb:alamb/backport_9820_57

Conversation

@alamb
Copy link
Copy Markdown
Contributor

@alamb alamb commented May 5, 2026

This PR:

Note: MutableBuffer::extend_bool_trusted_len is not present on the 57_maintenance line, so this backport omits the hunk for that API.

…s` (apache#9820)

- None.

BufferBuilder reserve paths relied on unchecked usize arithmetic when
calculating the required byte length. In optimized builds, very large
requested lengths could wrap before capacity growth.

This adds checked arithmetic for MutableBuffer byte length calculations
used by reserve and zero-extension paths.

Yes. This adds regression coverage for overflowing BufferBuilder length
calculations through reserve, append_n_zeroed, and advance.

Invalid requested lengths whose byte size cannot be represented without
overflow now panic consistently. There are no API changes.
@github-actions github-actions Bot added the arrow Changes to the arrow crate label May 5, 2026
self.resize(self.len + additional, 0);
let new_len = self
.len
.checked_add(additional)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

here is the new check

@alamb alamb marked this pull request as ready for review May 5, 2026 20:31
Copy link
Copy Markdown
Contributor

@etseidl etseidl left a comment

Choose a reason for hiding this comment

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

👍

@alamb alamb merged commit 2c35fce into apache:57_maintenance May 6, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants