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
Rust strings can freely contain null bytes. For example, "foo\0bar" is allowed in Rust and has a length of 7. Adding a null byte in Rust might result in a prefixed string.
As an alternative, consider using something like 0b10111111. All Rust strings are valid UTF-8, and a UTF-8 character can never begin with a 10-bit pattern, as this is the starting pattern of a continuation byte. Utilizing 0b10111111 in Rust strings would ensure that no byte slice derived from a string serves as a prefix for another.
Action Items:
Evaluate the possibility of using 0b10111111 as an alternative to null bytes.
Additional Context:
This consideration aims to prevent unintended string prefixing when adding bytes in Rust. This was raised by @DelSkaynhere
The text was updated successfully, but these errors were encountered:
Description:
Rust strings can freely contain null bytes. For example, "foo\0bar" is allowed in Rust and has a length of 7. Adding a null byte in Rust might result in a prefixed string.
As an alternative, consider using something like 0b10111111. All Rust strings are valid UTF-8, and a UTF-8 character can never begin with a 10-bit pattern, as this is the starting pattern of a continuation byte. Utilizing 0b10111111 in Rust strings would ensure that no byte slice derived from a string serves as a prefix for another.
Action Items:
Additional Context:
This consideration aims to prevent unintended string prefixing when adding bytes in Rust. This was raised by @DelSkayn here
The text was updated successfully, but these errors were encountered: