Fix leak & stale PCRE2_MD_COPIED_SUBJECT if pcre2_jit_match used with existing match context - #937
Merged
Merged
Conversation
NWilson
added a commit
that referenced
this pull request
Aug 31, 2026
Cherry-pick of 1dcd0cf and 1cad831 Fix leak & stale PCRE2_MD_COPIED_SUBJECT if pcre2_jit_match used with existing match context (#937) The problem is not that pcre2_jit_match() needs to add support for PCRE2_COPY_MATCHED_SUBJECT. Instead, if the passed-in context somehow contains a previously-copied subject (by non-JIT matcher using a global or cached subject) then it will be leaked, and worse, incorrectly free'd later. pcre2test: honor no_jit when used with jitfast (#946) `pcre2_jit_match()` ignores the PCRE2_NO_JIT option, so teach pcre2test to avoid calling it if the subject modifier that sets that option is used together with the option to call it directly. While at it, make jitverify more reliable and add a unittest to validate that PCRE2_NO_JIT is ignored in the fast JIt path.
NWilson
added a commit
that referenced
this pull request
Aug 31, 2026
Cherry-pick of 1dcd0cf and 1cad831 Fix leak & stale PCRE2_MD_COPIED_SUBJECT if pcre2_jit_match used with existing match context (#937) The problem is not that pcre2_jit_match() needs to add support for PCRE2_COPY_MATCHED_SUBJECT. Instead, if the passed-in context somehow contains a previously-copied subject (by non-JIT matcher using a global or cached subject) then it will be leaked, and worse, incorrectly free'd later. pcre2test: honor no_jit when used with jitfast (#946) `pcre2_jit_match()` ignores the PCRE2_NO_JIT option, so teach pcre2test to avoid calling it if the subject modifier that sets that option is used together with the option to call it directly. While at it, make jitverify more reliable and add a unittest to validate that PCRE2_NO_JIT is ignored in the fast JIt path.
NWilson
added a commit
that referenced
this pull request
Aug 31, 2026
Cherry-pick of 1dcd0cf and 1cad831 Fix leak & stale PCRE2_MD_COPIED_SUBJECT if pcre2_jit_match used with existing match context (#937) The problem is not that pcre2_jit_match() needs to add support for PCRE2_COPY_MATCHED_SUBJECT. Instead, if the passed-in context somehow contains a previously-copied subject (by non-JIT matcher using a global or cached subject) then it will be leaked, and worse, incorrectly free'd later. pcre2test: honor no_jit when used with jitfast (#946) `pcre2_jit_match()` ignores the PCRE2_NO_JIT option, so teach pcre2test to avoid calling it if the subject modifier that sets that option is used together with the option to call it directly. While at it, make jitverify more reliable and add a unittest to validate that PCRE2_NO_JIT is ignored in the fast JIt path.
NWilson
added a commit
that referenced
this pull request
Aug 31, 2026
Cherry-pick of 1dcd0cf and 1cad831 Fix leak & stale PCRE2_MD_COPIED_SUBJECT if pcre2_jit_match used with existing match context (#937) The problem is not that pcre2_jit_match() needs to add support for PCRE2_COPY_MATCHED_SUBJECT. Instead, if the passed-in context somehow contains a previously-copied subject (by non-JIT matcher using a global or cached subject) then it will be leaked, and worse, incorrectly free'd later. pcre2test: honor no_jit when used with jitfast (#946) `pcre2_jit_match()` ignores the PCRE2_NO_JIT option, so teach pcre2test to avoid calling it if the subject modifier that sets that option is used together with the option to call it directly. While at it, make jitverify more reliable and add a unittest to validate that PCRE2_NO_JIT is ignored in the fast JIt path.
NWilson
added a commit
that referenced
this pull request
Aug 31, 2026
Cherry-pick of 1dcd0cf and 1cad831 Fix leak & stale PCRE2_MD_COPIED_SUBJECT if pcre2_jit_match used with existing match context (#937) The problem is not that pcre2_jit_match() needs to add support for PCRE2_COPY_MATCHED_SUBJECT. Instead, if the passed-in context somehow contains a previously-copied subject (by non-JIT matcher using a global or cached subject) then it will be leaked, and worse, incorrectly free'd later. pcre2test: honor no_jit when used with jitfast (#946) `pcre2_jit_match()` ignores the PCRE2_NO_JIT option, so teach pcre2test to avoid calling it if the subject modifier that sets that option is used together with the option to call it directly. While at it, make jitverify more reliable and add a unittest to validate that PCRE2_NO_JIT is ignored in the fast JIt path.
NWilson
added a commit
that referenced
this pull request
Aug 31, 2026
Cherry-pick of 1dcd0cf and 1cad831 Fix leak & stale PCRE2_MD_COPIED_SUBJECT if pcre2_jit_match used with existing match context (#937) The problem is not that pcre2_jit_match() needs to add support for PCRE2_COPY_MATCHED_SUBJECT. Instead, if the passed-in context somehow contains a previously-copied subject (by non-JIT matcher using a global or cached subject) then it will be leaked, and worse, incorrectly free'd later. pcre2test: honor no_jit when used with jitfast (#946) `pcre2_jit_match()` ignores the PCRE2_NO_JIT option, so teach pcre2test to avoid calling it if the subject modifier that sets that option is used together with the option to call it directly. While at it, make jitverify more reliable and add a unittest to validate that PCRE2_NO_JIT is ignored in the fast JIt path.
deepin-ci-robot
added a commit
to deepin-community/pcre2
that referenced
this pull request
Sep 11, 2026
…f pcre2_jit_match used with ex CVE: CVE-2026-89161 (unknown) - Fix leak & stale PCRE2_MD_COPIED_SUBJECT if pcre2_jit_match used with existing match context Upstream: PCRE2Project/pcre2#937 Co-authored-by: hudeng <hudeng@deepin.org> Generated-By: qwen3.6-35b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem is not that pcre2_jit_match() needs to add support for PCRE2_COPY_MATCHED_SUBJECT. Instead, if the passed-in context somehow contains a previously-copied subject (by non-JIT matcher using a global or cached subject) then it will be leaked, and worse, incorrectly free'd later.
Fixes #920