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

Support null bytes in string inputs #131

Merged
merged 2 commits into from
Jan 20, 2024
Merged

Support null bytes in string inputs #131

merged 2 commits into from
Jan 20, 2024

Conversation

mudge
Copy link
Owner

@mudge mudge commented Jan 20, 2024

GitHub: #130

Ensure that whenever we pass Ruby string data into RE2 we use the data's explicit length as returned by RSTRING_LEN rather than relying on null-termination. RSTRING_PTR doesn't guarantee this (see https://docs.ruby-lang.org/en/3.3/extension_rdoc.html#label-VALUE+type+conversion) and we can end up either truncating input or, worse, over-reading.

@mudge mudge force-pushed the support-null-bytes branch 4 times, most recently from e362978 to 1e7c280 Compare January 20, 2024 14:25
mudge added 2 commits January 20, 2024 14:37
GitHub: #130

Ensure that whenever we pass Ruby string data into RE2 we use the data's
explicit length as returned by RSTRING_LEN rather than relying on
null-termination. RSTRING_PTR doesn't guarantee this (see
https://docs.ruby-lang.org/en/3.3/extension_rdoc.html#label-VALUE+type+conversion)
and we can end up either truncating input or, worse, over-reading.
While testing null-byte support, the Ruby interpreter segfaulted but the
use of RSpec's default "dots" formatter made it difficult to see which
test had caused the error. Switch to the more verbose "documentation"
format so it is obvious which test ran before any unexpected crash.
@mudge mudge force-pushed the support-null-bytes branch from 1e7c280 to a730bc4 Compare January 20, 2024 14:37
@mudge mudge merged commit a730bc4 into main Jan 20, 2024
77 checks passed
@mudge mudge deleted the support-null-bytes branch January 20, 2024 14:40
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

Successfully merging this pull request may close these issues.

1 participant