mirror of
https://github.com/gopher64/gopher64.git
synced 2026-04-26 07:25:58 +03:00
[GH-ISSUE #442] RUSTSEC-2024-0429: Unsoundness in Iterator and DoubleEndedIterator impls for glib::VariantStrIter #45
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/gopher64#45
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @github-actions[bot] on GitHub (Jun 26, 2025).
Original GitHub issue: https://github.com/gopher64/gopher64/issues/442
glib0.18.5The
VariantStrIter::impl_getfunction (called internally by implementations of theIteratorandDoubleEndedIteratortraits for this type) was unsound, resulting in undefined behaviour.An immutable reference
&pto a*mut libc::c_charpointer initialized toNULLwas passed as an argument to a C function that that mutates the pointer behind&pin-place (i.e. as an out-argument), which was unsound. After changes in recent versions of the Rust compiler, these unsound writes through&pnow seem to be completely disregarded when building theglibcrate with optimizations.This subsequently caused all calls of
VariantStrIter::impl_getto violate the safety requirements of thestd::ffi::CStr::from_ptrfunction - which requires its argument to be a valid pointer to a C-style string - resulting in crashes due toNULLpointer dereferences.This was fixed by passing the out-argument pointer explitly as
&mut pinstead of&p.This issue has been present since this code was initially added in
glibv0.15.0. The mismatch in mutability was likely missed (and not raised as an error by the compiler) because the C function wrapped byVariantStrIter::impl_getis variadic (glib_sys::g_variant_get_child), and the pointer in question is one of the variadic arguments.See advisory page for additional details.