Files
rust/library
Jonathan Brouwer 27aa1c5222 Rollup merge of #155707 - Manishearth:cstring-vuln, r=Mark-Simulacrum
Fix minor panic-unsoundness in CString::clone_into

`CString` must always contain a null byte, calling `mem::take` on its inner allocation puts it in an invalid state (causing UB if e.g. it hits `CString::drop`) that can be observed if the allocator panics.

Unfortunately, this solution allocates an intermediate 1-element `Box`. I'm not sure of a clean way to avoid that additional allocation; we could directly `realloc` if we want but it's tricky. Might be something we can do with `ManuallyDrop`.

I do have a gnarly miri test for this that uses a panicky allocator, but I'm not sure where it would go. Happy to push it up if someone has a suggestion.

Bug discovered by Rust Foundation Security using AI. I'm just helping with the patch as a member of wg-security-response. We do not believe this bug needs embargo, it is a soundness fix for hard-to-trigger unsoundness.
2026-04-26 19:06:28 +02:00
..
2026-04-24 00:15:42 +00:00
2026-01-26 10:57:35 +00:00
2026-02-22 19:59:25 +01:00
2026-01-26 10:59:16 +00:00