You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Calculate a length of a `NdpOption`'s payload.
fn ndp_option_payload_length(option: &NdpOptionPacket) -> usize {
let len = option.get_length();
if len > 0 {
((len * 8) - 2) as usize
} else {
0
}
}
Value "len" is of type u8, so multiplication "len * 8" is done with 8-bit unsigned arithmetic. If len is 32 or more, the result is overflow; this is UB. The correct calculation, of course, is "len as usize * 8".
The text was updated successfully, but these errors were encountered:
In https://github.com/libpnet/libpnet/blob/main/pnet_packet/src/icmpv6.rs#L304, length calculation is as follows:
Value "len" is of type u8, so multiplication "len * 8" is done with 8-bit unsigned arithmetic. If len is 32 or more, the result is overflow; this is UB. The correct calculation, of course, is "len as usize * 8".
The text was updated successfully, but these errors were encountered: