Skip to content

[57_maintenance] Prevent repeat slice length overflow (#9819)#9920

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

[57_maintenance] Prevent repeat slice length overflow (#9819)#9920
alamb merged 1 commit intoapache:57_maintenancefrom
alamb:alamb/backport_9819_57

Conversation

@alamb
Copy link
Copy Markdown
Contributor

@alamb alamb commented May 5, 2026

# Which issue does this PR close?

- None.

# Rationale for this change

MutableBuffer repeated slices used unchecked usize arithmetic when
calculating the number of bytes to reserve. In optimized builds, very
large repeat counts could wrap the capacity calculation before copying
repeated bytes.

# What changes are included in this PR?

This adds checked arithmetic for repeated slice byte length validation
before reserving capacity and copying repeated data.

# Are these changes tested?

Yes. This adds regression coverage for overflowing repeated slice length
calculations.

# Are there any user-facing changes?

Invalid repeat counts whose requested byte length 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
@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.

carbon copy 😄

@alamb
Copy link
Copy Markdown
Contributor Author

alamb commented May 6, 2026

carbon copy 😄

Yeah, maybe all the process is overboard for this , but I figured it was easy to incrementally review / audit what is going on

@alamb alamb merged commit 090e8cb into apache:57_maintenance May 6, 2026
26 checks passed
@etseidl
Copy link
Copy Markdown
Contributor

etseidl commented May 6, 2026

Yeah, maybe all the process is overboard for this , but I figured it was easy to incrementally review / audit what is going on

I'd prefer many small changes to one big eye-bleedy one 😅

@alamb alamb deleted the alamb/backport_9819_57 branch May 6, 2026 15:28
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