Skip to content

Soundness: RelativePath is treated as transparent but it isn't #2692

Description

#[derive()]
pub struct RelativePath {
inner: BStr,
}

impl RelativePath {
fn new_unchecked(value: &BStr) -> Result<&RelativePath, Error> {
// SAFETY: `RelativePath` is transparent and equivalent to a `&BStr` if provided as reference.
#[allow(unsafe_code)]
unsafe {
std::mem::transmute(value)
}

The unsafe code here is incorrect.

Furthermore, I don't actually think we can assume much about Result's layout there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions