[pcre-dev] [Bug 2086] New: Bug in Regex match rule

Top Page
Delete this message
Author: admin
Date:  
To: pcre-dev
Subject: [pcre-dev] [Bug 2086] New: Bug in Regex match rule
https://bugs.exim.org/show_bug.cgi?id=2086

            Bug ID: 2086
           Summary: Bug in Regex match rule
           Product: PCRE
           Version: 8.40
          Hardware: x86
                OS: Linux
            Status: NEW
          Severity: bug
          Priority: medium
         Component: Code
          Assignee: ph10@???
          Reporter: yjaeyong@???
                CC: pcre-dev@???


For the following regex: (02-)?[0-9]{3}-[0-9]{3}

It doesn't correctly match the string: 02-123-123

the longest match is "123-123"

Here is the code snippet that reproduces this bug:


#include <stdio.h>
#include <string.h>
#include "pcre.h"


int main(void)
{
        char *regex = "(02-)?[0-9]{3}-[0-9]{3}";
        const char *err;
        int erro, rc;
        size_t size;
        pcre *re;
        char *input = "02-123-123";
        int ovec[3], ret;;
        int workspace[512];



        re = pcre_compile(regex, 0, &err, &erro, NULL);


        if(!re) {
                printf("ERROR\n");
        }


        rc = pcre_fullinfo(re, NULL, PCRE_INFO_SIZE, &size);
        printf("SIZE: %d\n", (int)size);


        ret = pcre_dfa_exec(re, NULL, input, strlen(input), 0,
                        PCRE_PARTIAL_SOFT, ovec, 3, workspace, 512);
        memset(workspace, 0, sizeof(workspace));


        fprintf(stderr, "JYD: ret = %d [%d, %d, %d]\n", ret, ovec[0], ovec[1],
ovec[2]);
        fprintf(stderr, "REG: %s / INPUT: %s\n", regex, input);


        return 0;
}


--
You are receiving this mail because:
You are on the CC list for the bug.