Skip to content

Possible undefined behavior in function Dataset::try_from #4

Description

@rikkaii

Hi, I'm conducting a research on Rust security and found a bug in this crate:
The function Vec::from_raw_parts should not use the pointer from the FFI object, it should be a pointer allocated using the global allocator. Otherwise, it may cause a undefined behavior.
See the document for detail Vec::from_raw_parts

spglib-rs/src/dataset.rs

Lines 98 to 107 in 0f3832a

let rotations = unsafe {
Vec::from_raw_parts(ptr.rotations, n_operations as usize, n_operations as usize)
};
let translations = unsafe {
Vec::from_raw_parts(
ptr.translations,
n_operations as usize,
n_operations as usize,
)
};

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