Bug 25322 - regex mishandles back-references inside interval expressions
Summary: regex mishandles back-references inside interval expressions
Status: NEW
Alias: None
Product: glibc
Classification: Unclassified
Component: regex (show other bugs)
Version: 2.30
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-29 20:35 UTC by eggert
Modified: 2021-06-15 23:40 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
C program illustrating bug with back-references inside intervals (151 bytes, text/x-csrc)
2019-12-29 20:35 UTC, eggert
Details

Note You need to log in before you can comment on or make changes to this bug.
Description eggert 2019-12-29 20:35:01 UTC
Created attachment 12153 [details]
C program illustrating bug with back-references inside intervals

The glibc regular expression code mishandles regular expressions such as:

   .*((.)\2){2}$

as it does not backtrack enough to find a match that satisfies the back-references when they are used twice.

To reproduce the problem, compile and run the attached file backrefbug.c. It will exit with status 2, whereas the correct exit status is 0.

This bug was originally reported against GNU 'grep' here:

https://bugs.gnu.org/26864

and you can find more test cases by reading that bug report.
Comment 1 Ahmed Sayeed 2021-05-25 19:52:12 UTC Comment hidden (spam)
Comment 2 Leslie Brown 2021-06-15 23:40:15 UTC Comment hidden (spam)