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

  • MR title and description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • Latest Merge Result pipeline is green.
  • When ready for review, MR is labeled workflowready for review per the Distribution MR workflow.

For GitLab team members

If you don't have access to this, the reviewer should trigger these jobs for you during the review process.

  • The manual Trigger:ee-package jobs have a green pipeline running against latest commit.
  • If config/software or config/patches directories are changed, make sure the build-package-on-all-os job within the Trigger:ee-package downstream pipeline succeeded.
  • If you are changing anything SSL related, then the Trigger:package:fips manual job within the Trigger:ee-package downstream pipeline must succeed.
  • If CI configuration is changed, the branch must be pushed to dev.gitlab.org to confirm regular branch builds aren't broken.

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes.
  • Documentation created/updated.
  • Tests added.
  • Integration tests added to GitLab QA.
  • Equivalent MR/issue for the GitLab Chart opened.
  • Validate potential values for new configuration settings. Formats such as integer 10, duration 10s, URI scheme://user:passwd@host:port may require quotation or other special handling when rendered in a template and written to a configuration file.

Merge request reports

Loading
Loading