Bug 119224 - regcomp returns false when true is correct return
Summary: regcomp returns false when true is correct return
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 8.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-03-26 17:43 UTC by Ronald Van Iwaarden
Modified: 2016-11-24 15:21 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-03-26 17:48:30 UTC
Embargoed:


Attachments (Terms of Use)

Description Ronald Van Iwaarden 2004-03-26 17:43:16 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b)
Gecko/20030827

Description of problem:
The following code gives a response of "Didn't find a match (for
regexec)." when it should give "Success."  Originally submitted to gcc
but they said this is a bug in glibc and to report to vendor.  Problem
does not show on glibc-2.2.5-40.

Using gcc version 3.2

#include <iostream>
#include <sys/types.h>
#include <regex.h>

const char* haystack = 
"2\n3";

const char* needle =
".+\n3";


int main()
{
  using namespace std;
  regex_t r;
  int failed_p = regcomp(&r, needle,
			       REG_EXTENDED | REG_NOSUB);
  int result = regexec(&r, haystack, 0, NULL, 0);
  switch (result)
  {
  case REG_NOERROR:
    cout<<"Success."<<endl;break;
  case REG_NOMATCH:
    cout<<"Didn't find a match (for regexec)."<<endl;break;
  case REG_BADPAT:
    cout<<" Invalid pattern."<<endl;break;
  case REG_ECOLLATE:
    cout<<" Not implemented."<<endl;break;
  case REG_ECTYPE:
    cout<<" Invalid character class name."<<endl;break;
  case REG_EESCAPE:
    cout<<" Trailing backslash."<<endl;break;
  case REG_ESUBREG:
    cout<<" Invalid back reference."<<endl;break;
  case REG_EBRACK:
    cout<<" Unmatched left bracket."<<endl;break;
  case REG_EPAREN:
    cout<<" Parenthesis imbalance."<<endl;break;
  case REG_EBRACE:
    cout<<" Unmatched \\{."<<endl;break;
  case REG_BADBR:
    cout<<" Invalid contents of \\{\\}."<<endl;break;
  case REG_ERANGE:
    cout<<" Invalid range end."<<endl;break;
  case REG_ESPACE:
    cout<<" Ran out of memory."<<endl;break;
  case REG_BADRPT:
    cout<<" No preceding re for repetition op."<<endl;break;
  case REG_EEND:
    cout<<" Premature end."<<endl;break;
  case REG_ESIZE:
    cout<<" Compiled pattern bigger than 2^16 bytes."<<endl;break;
  case REG_ERPAREN:
    cout<<" Unmatched ) or \\); not returned from regcomp."<<endl;break;
  default:
    cout<<"unknown result:"<<result<<endl;
  }
}

Version-Release number of selected component (if applicable):
glibc-2.2.93-5

How reproducible:
Always

Steps to Reproduce:
1.compile code
2.run
3.
    

Actual Results:  Outputs "Didn't find a match (for regexec)."

Expected Results:  Output of "Success."

Additional info:

Comment 1 Jakub Jelinek 2004-03-26 17:48:30 UTC
Works just fine with glibc-2.3.2-95.17 (RHEL3 U2) or 2.3.3-18
(Fedora Core 2 test2).
RHL 8.0 is no longer supported FYI.

Comment 2 Ronald Van Iwaarden 2004-03-26 18:46:58 UTC
Understand RH 8.0 is no longer supported.  Thought it might be
worthwhile to investigate to determine if the problem was truly fixed,
fixed accidentally, fixed partially, or masked.

Thanks for the check on Fedora Core 2 test2.

--Ron

Comment 3 Jakub Jelinek 2004-03-26 18:56:44 UTC
There have been more than fifty regex fixes since November 2003 in glibc.


Note You need to log in before you can comment on or make changes to this bug.