Skip to content

Conversation

@headius
Copy link
Contributor

@headius headius commented May 3, 2025

Fix GH-152

CRuby can walk off the end because there's always a null byte. In JRuby, the byte array is often (usually?) the exact size of the string. So we need to check if len++ walked off the end.

This code was ported from a version by @byroot in #127 but I missed adding this check due to a lack of tests. A test is included for both "-" and "+" parsing.

@headius
Copy link
Contributor Author

headius commented May 3, 2025

cc @gettalong @kou I think this is the last strscan-related fix from HexaPDF tests.

@headius
Copy link
Contributor Author

headius commented May 3, 2025

JRuby CI failures will be fixed by #151.

@kou kou changed the title Check if len++ walked off the end jruby: Check if len++ walked off the end May 3, 2025
@kou
Copy link
Member

kou commented May 3, 2025

Could you rebase on main?

headius added 2 commits May 2, 2025 21:37
In CRuby, there's always a null byte so you can walk off without
a fault. In JRuby, String bytes typically are exactly the length
of the string, so walking off the end triggers an error.

Fixes #152
@headius headius force-pushed the no_walk_off_end branch from d824b29 to 2dc98a1 Compare May 3, 2025 02:37
@headius
Copy link
Contributor Author

headius commented May 3, 2025

@kou Done!

@kou kou merged commit 1abe4ca into master May 3, 2025
74 of 76 checks passed
@kou kou deleted the no_walk_off_end branch May 3, 2025 04:26
@kou
Copy link
Member

kou commented May 3, 2025

Released.

matzbot pushed a commit to ruby/ruby that referenced this pull request May 8, 2025
(ruby/strscan#153)

Fix ruby/strscan#152

CRuby can walk off the end because there's always a null byte. In JRuby,
the byte array is often (usually?) the exact size of the string. So we
need to check if len++ walked off the end.

This code was ported from a version by @byroot in
ruby/strscan#127 but I missed adding this check
due to a lack of tests. A test is included for both "-" and "+" parsing.

ruby/strscan@1abe4ca556
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.

jruby: ArrayIndexOutOfBounds running HexaPDF tokenizer tests

2 participants