Restore buffer after an ACCEPT inside an scan substring block#771
Restore buffer after an ACCEPT inside an scan substring block#771NWilson merged 1 commit intoPCRE2Project:masterfrom
Conversation
testdata/testoutput2
Outdated
|
|
||
| /(a)(b+)(*scs:(1)a(*ACCEPT))(\2)/ | ||
| abbb | ||
| 0: abb |
There was a problem hiding this comment.
isn't this the current/expected output in 10.45 and HEAD?
There was a problem hiding this comment.
Yes. This patch is a bugfix.
There was a problem hiding this comment.
Apologies for not being clear enough, but the point I was trying to make is that the test case doesn't show the bug, at least on my system:
PCRE2 version 10.45 2025-02-05 (8-bit)
re> /(a)(b+)(*scs:(1)a(*ACCEPT))(\2)/BI
------------------------------------------------------------------
Bra
CBra 1
a
Ket
CBra 2
b+
Ket
Scan substring
1 Capture ref
a
*ASSERT_ACCEPT
Ket
CBra 3
\2
Ket
Ket
End
------------------------------------------------------------------
Capture group count = 3
Max back reference = 2
First code unit = 'a'
Subject length lower bound = 1
data> abbb
0: abb
1: a
2: b
3: b
There was a problem hiding this comment.
True. The (PCRE2_SIZE)(mb->end_subject - eptr) < length in line 488 is 18446744073709551613 < length and does not true. A better test case is needed.
There was a problem hiding this comment.
The new test should be better. Thank you for noticing this.
There was a problem hiding this comment.
I think we are arguing over semantics, but yes, you are correct that this PR alone solves both bugs, including the subject over reads in match_ref that could cause crashes.
There was a problem hiding this comment.
Thank you for confirming! I will include only this fix in the 10.46 security release, in order to make minimal changes in this release.
There was a problem hiding this comment.
Btw why not 10.45.1? The increase of major usually means new features.
There was a problem hiding this comment.
Presume that moving to a 3 digit version number might be a good idea if we are going to do this regularly, but definitely would had been a bigger change and taken a lot longer than this took.
I had to admit I am impressed that it went so smoothly, including a CVE number being assigned.
There was a problem hiding this comment.
That's right. Changing the format of the version number to two digits has the potential to be disruptive to downstream consumers. Plus, we have API functions that expect a two-digit number, and the special VERSION pattern syntax...
It simply had to be 10.46.
Anyway, thanks to both of you for fixing this (Zoltan) and reviewing (Carlo).
|
Not a regression, as it seems to behave the same with or without this patch, but why is this correct? I was expecting |
|
The last one matches because of backtracking. |
|
Got it; do you have an example with (*ACCEPT) being relevant? |
Probably something like this. There will be a buffer overread, although if the next character in the buffer is not |
|
I have decided I will make a dedicated security release, and notify the mailing list. For a widely-used library such as PCRE2, I would like to take this seriously. I should have acted on it sooner. That is my fault. |
No description provided.