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
Since it does not place any requirements on the input type besides having a len method, an IndexMut impl, and a Deref<Target=[u8]> impl, the returned values from these methods may not actually be valid (e.g. the user could write a type which has a len() method that returns 500 and a Deref impl that returns a zero-sized buffer).
However this is ultimately mitigated because the usage of this macro is restricted to only fixed-size byte buffers which are sized for primitives. It may be worth considering doing more type validation on the macro inputs so that the safety of these macros doesn't depend on the specific usages.
The following macros have similar properties:
ixx!
uxx!
Additionally, these and other macros have similar behavior where if they are passed 0-sized buffers, lines like this would lead to undefined behavior:
Several of the impl macros are technically unsound (although their usages do not lead to undefined behavior).
Take
hex_format
as an example:ufmt/src/impls/hex.rs
Lines 3 to 20 in d95831b
Since it does not place any requirements on the input type besides having a
len
method, anIndexMut
impl, and aDeref<Target=[u8]>
impl, the returned values from these methods may not actually be valid (e.g. the user could write a type which has alen()
method that returns 500 and aDeref
impl that returns a zero-sized buffer).However this is ultimately mitigated because the usage of this macro is restricted to only fixed-size byte buffers which are sized for primitives. It may be worth considering doing more type validation on the macro inputs so that the safety of these macros doesn't depend on the specific usages.
The following macros have similar properties:
ixx!
uxx!
Additionally, these and other macros have similar behavior where if they are passed 0-sized buffers, lines like this would lead to undefined behavior:
ufmt/src/impls/uxx.rs
Line 10 in d95831b
This safety issue is also mitigated because the macro is not exported, but generic use of this macro wouldn't be sound.
The text was updated successfully, but these errors were encountered: