Closed manueljacob closed 9 months ago
Thanks for reporting this, @manueljacob.
This should now be fixed in the newly released 2.7.0, can you please let me know if that resolves your issue?
It should also fix handling of null bytes across the library where possible (note that null bytes are not valid in capturing group names as that is dictated by RE2 itself).
It works for me, thank you!
I’d expect
RE2.QuoteMeta("abc\0def")
to return"abc\\x00def"
but it returns"abc"
. The reason is that in https://github.com/mudge/re2/blob/v2.6.0/ext/re2/re2.cc#L1756,RSTRING_PTR
is used to convert the Ruby String tochar *
.RE2::QuoteMeta
then interprets it as a null-terminated string. In addition to the truncation problem, according to the Ruby documentation, the result ofRSTRING_PTR
may not be NUL-terminated, potentially leading to a buffer over-read.