rust-netlink / netlink-packet-route

Rust crate for the netlink route protocol
https://docs.rs/netlink-packet-route/
Other
28 stars 48 forks source link

Check NLA buffers on creation #129

Closed Jeff-A-Martin closed 3 months ago

Jeff-A-Martin commented 4 months ago

Replace calls to NlaBuffer::new with NlaBuffer::new_checked. This ensures that the parsing of individual NLAs is guaranteed to have a valid NlaBuffer (i.e. sufficient bytes to attempt parsing). Without this check, the parsing logic of several attributes would panic if provided with an NlaBuffer that was too short (e.g. length of 1).

One such example is the parsing of LinkVfPort, which would have panicked when calling buf.value() on line 61 of src/link/sriov/vf_port.rs.