Skip to content

Possible unsound public API #691

Closed
Closed
@charlesxsh

Description

@charlesxsh

pub fn f8_impl<M: Machine>(mach: M, state: &mut [vec128_storage; 8], data: *const u8) {
#[allow(clippy::cast_ptr_alignment)]
let data: *const M::u128x1 = data.cast();
let mut y = X8::<M>(
mach.unpack(state[0]),
mach.unpack(state[1]),
mach.unpack(state[2]),
mach.unpack(state[3]),
mach.unpack(state[4]),
mach.unpack(state[5]),
mach.unpack(state[6]),
mach.unpack(state[7]),
);
unsafe {
y.0 ^= ptr::read_unaligned(data);
y.1 ^= ptr::read_unaligned(data.offset(1));
y.2 ^= ptr::read_unaligned(data.offset(2));
y.3 ^= ptr::read_unaligned(data.offset(3));
}
for rc in crate::consts::E8_BITSLICE_ROUNDCONSTANT.chunks_exact(7) {
unroll7!(j, {
y = ss(y, unsafe { X2Bytes::<M> { bytes: rc[j] }.x2 });
y = l(y);

Hi there, the parameter data is read at line 112-115 without sufficient checks, which might cuase memory issue. Since this is publicly accessible to library user, would you consider to mark the function unsafe? or make it private in the crate.

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