Skip to content

Conversation

kawadakk
Copy link
Contributor

@kawadakk kawadakk commented Aug 8, 2025

Fixes the following bugs:

  • StrV::reserve can return without actually reserving if additional is too large (>= usize::MAX - self.len()) and overflow checking is disabled
  • StrV::extend_from_slice can incorrectly skip StrV::reserve before writing elements if it is given a ZST slice containing a large number of elements (>= usize::MAX - self.len()) and overflow checking is disabled
  • StrV::extend_from_slice is not panic safe
  • <StrVRef as PartialEq<[&str]>>::eq incorrectly evaluates to false if two slices have different numbers of elements but their prefixes match

The left hand side of the condition `self.len + additional + 1 <= self.
capacity` could overflow and wrap around if `additional` was set to a
huge value, causing `reserve` to return without reserving a specified
capacity.
The left hand side of the condition `self.len + other.len() + 1 <= self.
capacity` could overflow and wrap around if `other` contained a large
number of elements, causing it to proceed to the copying code without
calling `reserve`.
We need to ensure that `self` is null-terminated even if `<S as AsRef<
str>>::as_ref` panics.
@sdroege sdroege added the needs-backport PR needs backporting to the current stable branch label Aug 8, 2025
@sdroege
Copy link
Member

sdroege commented Aug 8, 2025

The CI failures are unrelated, you can ignore them :)

Once you updated the other parts, I'll merge this and get a bugfix release with that (and the other pending fixes) out. Thanks for fixing these!

sdroege added 2 commits August 9, 2025 17:18
Also check lenghts in various `StrV` tests.
We need to ensure that `self` is null-terminated even if writing the previous items panics.
@sdroege
Copy link
Member

sdroege commented Aug 9, 2025

Fixing those other occurrences now to get a bugfix release out.

@sdroege sdroege merged commit 2477663 into gtk-rs:main Aug 9, 2025
46 of 48 checks passed
@sdroege sdroege added backported PR was backported to the current stable branch and removed needs-backport PR needs backporting to the current stable branch labels Aug 9, 2025
@kawadakk kawadakk deleted the fix-strv branch August 18, 2025 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported PR was backported to the current stable branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants