Add Ruby regexp repeat ID overflow patch for 3.3, 3.4 and 4.0
What does this MR do?
Add Ruby regexp repeat ID overflow patch for 3.3, 3.4 and 4.0.
Backport https://github.com/ruby/ruby/pull/16801 to Ruby 3.3, 3.4 and 4.0.
Onigmo stores range-repeat and null-check IDs in a signed 16-bit bytecode operand but counts them in an int, so a regexp with more than 32,767 of either wraps the ID negative. At match time the negative ID indexes the repeat stack, an out-of-bounds write. The fix makes the compiler reject such a pattern with RegexpError ("too many range repeat", "too many null check") instead.
The fix is only on upstream master (Ruby 4.1): it is not on ruby_3_3, ruby_3_4 or ruby_4_0, so the patch applies to 3.3, 3.4 and 4.0. Each variant inserts the lines of upstream commit 493d26dcdea8b2f0ac5d28e057b401bc809e7fae unchanged. On 3.3 and 3.4 the hunk context differs from upstream because the regexp-program-size patch already added ONIGERR_TOO_BIG_COMPILED_PROGRAM (-226) where the new -224 and -225 codes go; the codes, error messages and tests are placed as on upstream master. The 4.0 variant differs from upstream only in line numbers, as 4.0.7 does not carry the program-size backport yet.
Checklist
See Definition of done.
For anything in this list which will not be completed, please provide a reason in the MR discussion
Required
- Merge Request Title, and Description are up to date, accurate, and descriptive
- MR targeting the appropriate branch
- MR has a green pipeline on GitLab.com
- When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow
Expected (please provide an explanation if not completing)
- Test plan indicating conditions for success has been posted and passes
- Documentation created/updated
- Integration tests added to GitLab QA
- The impact any change in container size has should be evaluated
- New dependencies are managed with GitLab forked renovatebot