Bug 25322

Summary: regex mishandles back-references inside interval expressions
Product: glibc Reporter: eggert
Component: regexAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: afarabdelwahab, ahmedsayeed1982, ampva300, bhtrananh8, drepper.fsp, lexenluis, lmminformation2020, namboru, noithatduyanh.1990, sherrixotyv29
Priority: P2 Flags: fweimer: security-
Version: 2.30   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Attachments: C program illustrating bug with back-references inside intervals

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)
Comment 3 Ahmed Sayeed 2021-06-27 17:41:02 UTC Comment hidden (spam)
Comment 4 lisa ray 2021-07-07 13:08:56 UTC Comment hidden (spam)
Comment 5 lisa ray 2021-07-07 13:48:58 UTC Comment hidden (spam)
Comment 8 Joe Anderson 2021-07-13 00:17:55 UTC Comment hidden (spam)
Comment 9 Sherry 2021-07-15 01:14:47 UTC Comment hidden (spam)
Comment 10 goda omar 2021-07-16 13:50:01 UTC Comment hidden (spam)
Comment 11 goda omar 2021-07-16 13:51:34 UTC Comment hidden (spam)
Comment 12 goda omar 2021-07-16 13:52:05 UTC Comment hidden (spam)
Comment 15 Sherry 2021-07-21 03:36:01 UTC Comment hidden (spam)
Comment 18 bh ta 2021-07-24 02:36:16 UTC Comment hidden (spam)
Comment 19 lisa ray 2021-07-25 08:36:01 UTC Comment hidden (spam)
Comment 21 Linda 2021-07-28 07:24:55 UTC Comment hidden (spam)