Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address Rust String Null Byte Handling #12

Closed
arriqaaq opened this issue Jan 11, 2024 · 1 comment
Closed

Address Rust String Null Byte Handling #12

arriqaaq opened this issue Jan 11, 2024 · 1 comment

Comments

@arriqaaq
Copy link
Contributor

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:

  • 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 @DelSkayn here

@arriqaaq
Copy link
Contributor Author

closing in favor of #13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant