Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Misaligned pointer exposure in <String as TensorType>::unpack #416

Open
Labels
@shinmao

Description

The source of unsoundness

Hi, we found an unsound implementation in unpack which could create a misaligned pointer:

rust/src/lib.rs

Lines 900 to 903 in 62a3019

fn unpack(data: &[u8], count: usize) -> Result<Vec<Self>> {
let tstrings =
unsafe { slice::from_raw_parts(data.as_ptr() as *const tf::TF_TString, count) };
let mut out = Vec::with_capacity(count);

At line 902, the u8 pointer would cast to TF_TString which had stronger alignment requirements. The misaligned pointer passed to slice::from_raw_parts would break the safety guarantee. Please check and happy to have a discussion:)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /