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
The code in bin.rs is unsafe and causes a panic (in read_u16/read_u32). It'd probably be a much better (and safer) idea to either use Nom or to interpret the bytes as a string and read the u16s/u32s via uX::from_str_radix.
The text was updated successfully, but these errors were encountered:
ethindp
changed the title
Serious bug (4.2.4): binary manipulation code is full of dangerous hacks
Serious bug (4.2.4): binary manipulation code (bin.rs) has code that causes panics
Aug 21, 2023
Hi, thanks for the feedback.
The first thing is that the code in bin.rs is there to rebuild u16 and u32 values from slices of bytes that are their binary representation. Those bytes are not strings, so that rules out uX::from_str_radix. uX::from_be_bytes would be more appropriate and would fix this problem.
To clarify a little bit, the code does not use unsafe, although it CAN panic in some cases when the data being loaded is not correct ; but it would argue this is an acceptable hypothesis, if the data from the automaton is garbage, this is catastrophic at runtime.
The code in
bin.rs
is unsafe and causes a panic (inread_u16
/read_u32
). It'd probably be a much better (and safer) idea to either use Nom or to interpret the bytes as a string and read the u16s/u32s viauX::from_str_radix
.The text was updated successfully, but these errors were encountered: