Skip to content

Unsound usages of unsafe implementation about c_void #5

Description

@llooFlashooll

Hi, I am scanning this crate in the latest version using my own static analyzer tool.

Unsafe pointer conversion is found at:

pub fn set_denoiser_settings<T>(
        &mut self,
        identifier: ffi::Identifier,
        reblur_settings: &T,
    ) -> Result<(), ffi::Result> {
        unsafe {
            ffi::SetDenoiserSettings(
                self.0,
                identifier,
                reblur_settings as *const _ as *const c_void,
            )
            .ok(())
        }
    }

This unsound implementation would create memory issues such as overflow, underflow, or misalignment. The attacker can manipulate the argument reblur_settings associated with the c_void pointer with an unexpected type or layout, which can lead to an out-of-bounds memory access bug. The c_void pointer is passed through the FFI (SetDenoiserSettings), which can further corrupt the C/C++ code.

This would cause undefined behaviors in Rust. Adversaries can manipulate the associated argument to cause memory safety bugs. I am reporting this issue for your attention.

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