Skip to content

Possible Unsound Safe API #3

@charlesxsh

Description

@charlesxsh
impl EndpointBuffer {
    pub fn new(offset: usize, size: usize) -> Self {
        let addr = unsafe { EP_MEM_PTR.add(offset) };
        let mem = unsafe { slice::from_raw_parts_mut(addr, size) };
        Self(mem)
    }
}

In public accessible function EndpointBuffer::new, it accepts parameters offset and size and used in pointer calculation and slice creation but lack of sufficient checks, which might cause memory issues. In Rust, we should not cause any memory issues if merely using safe functions.

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