Skip to content

Dangerous unsafe in impl_reply #84

@sosthene-nitrokey

Description

@sosthene-nitrokey

https://github.com/trussed-dev/trussed/blob/main/src/api/macros.rs#L96

    impl From<Reply> for $reply {
        fn from(reply: Reply) -> reply::$reply {
            match reply {
                Reply::$reply(reply) => reply,
                _ => { unsafe { unreachable_unchecked() } }
            }
        }
    }

This unsafe is not sound and this impl is part of the public API. I think we could replace it with a panic!, since it is only used by PollClient::request. To reduce the risk of panicking I would instead use TryFrom.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions