Skip to content

Enable unreachable-pub for the interpreter #823

@charlesxsh

Description

@charlesxsh

crates/interpreter/src/toctou.rs:111

pub fn get(xs: &[u8], i: usize) -> u8 {
    #[cfg(not(feature = "toctou"))]
    return unsafe { *xs.get_unchecked(i) };
    #[cfg(feature = "toctou")]
    xs[i]
}

pub fn split_at(xs: &[u8], mid: usize) -> (&[u8], &[u8]) {
    #[cfg(not(feature = "toctou"))]
    return unsafe { xs.split_at_unchecked(mid) };
    #[cfg(feature = "toctou")]
    xs.split_at(mid)
}

Functions get and split_atare public and safe, they accept parameters and used in unsafe functions without sufficient checks (when certain feature flag is set up), which might cause memory risks. In Rust, we should not face any security risks when merely using safe function.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions