Skip to content

Commit

Permalink
Deal with integer overflow bug in recent variable length lookbehind c…
Browse files Browse the repository at this point in the history
…ode. Fixes ClusterFuzz 61627.
  • Loading branch information
PhilipHazel committed Aug 21, 2023
1 parent 7331d5c commit 1b291b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pcre2_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -9658,8 +9658,8 @@ for (;; pptr++)
if (max != REPEAT_UNLIMITED)
{
if (lastitemlength != 0 && /* Should not occur, but just in case */
min != 0 &&
INT_MAX/lastitemlength < max - 1)
max != 0 &&
(INT_MAX - branchlength)/lastitemlength < max - 1)
{
*errcodeptr = ERR87; /* Integer overflow; lookbehind too big */
return -1;
Expand Down
2 changes: 2 additions & 0 deletions testdata/testinput2
Original file line number Diff line number Diff line change
Expand Up @@ -5973,4 +5973,6 @@ a)"xI

/(?<=(()()()()()()()()()()()()()(()()()()(())()()()()(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()(())()()()()(()()()()()()(()()()()()()()()()()()()()()()()()()()()()(())()()()()(()()()()()()()()()()()()()(()()()()()()()()()()()()()(()())))))))))/

/(?<!( {65054}){0,44965})/auto_callout

# End of testinput2
3 changes: 3 additions & 0 deletions testdata/testoutput2
Original file line number Diff line number Diff line change
Expand Up @@ -17803,6 +17803,9 @@ Failed: error 187 at offset 0: lookbehind assertion is too long

/(?<=(()()()()()()()()()()()()()(()()()()(())()()()()(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()(())()()()()(()()()()()()(()()()()()()()()()()()()()()()()()()()()()(())()()()()(()()()()()()()()()()()()()(()()()()()()()()()()()()()(()())))))))))/

/(?<!( {65054}){0,44965})/auto_callout
Failed: error 187 at offset 0: lookbehind assertion is too long

# End of testinput2
Error -70: PCRE2_ERROR_BADDATA (unknown error number)
Error -62: bad serialized data
Expand Down

0 comments on commit 1b291b2

Please sign in to comment.