summaryrefslogtreecommitdiff
path: root/pcre_compile.c
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2014-05-28 11:10:58 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2014-05-28 11:10:58 +0000
commite809f069a7e3e16d19d2df8bc87cae203635736f (patch)
treea612fbbc3ca49805869d81d2c31af337c0d941e6 /pcre_compile.c
parent7535acc4e3072709aacf5179e8e8e14200da4a17 (diff)
downloadpcre-e809f069a7e3e16d19d2df8bc87cae203635736f.tar.gz
Fix two bugs concerned with duplicate named patterns.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1482 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcre_compile.c')
-rw-r--r--pcre_compile.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/pcre_compile.c b/pcre_compile.c
index 1234db0..b0e0980 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -5982,7 +5982,7 @@ for (;; ptr++)
just adjust the length as if we had. Do some paranoid checks for
potential integer overflow. The INT64_OR_DOUBLE type is a 64-bit
integer type when available, otherwise double. */
-
+
if (lengthptr != NULL)
{
int delta = (repeat_min - 1)*length_prevgroup;
@@ -6700,7 +6700,8 @@ for (;; ptr++)
ptr++;
}
namelen = (int)(ptr - name);
- if (lengthptr != NULL) *lengthptr += IMM2_SIZE;
+ if (lengthptr != NULL && (options & PCRE_DUPNAMES) != 0)
+ *lengthptr += IMM2_SIZE;
}
/* Check the terminator */
@@ -6761,9 +6762,11 @@ for (;; ptr++)
for (; i < cd->names_found; i++)
{
slot += cd->name_entry_size;
- if (STRNCMP_UC_UC(name, slot+IMM2_SIZE, namelen) != 0) break;
+ if (STRNCMP_UC_UC(name, slot+IMM2_SIZE, namelen) != 0 ||
+ (slot+IMM2_SIZE)[namelen] != 0) break;
count++;
}
+
if (count > 1)
{
PUT2(code, 2+LINK_SIZE, offset);
@@ -7112,6 +7115,12 @@ for (;; ptr++)
/* Count named back references. */
if (!is_recurse) cd->namedrefcount++;
+
+ /* If duplicate names are permitted, we have to allow for a named
+ reference to a duplicated name (this cannot be determined until the
+ second pass). This needs an extra 16-bit data item. */
+
+ if ((options & PCRE_DUPNAMES) != 0) *lengthptr += IMM2_SIZE;
}
/* In the real compile, search the name table. We check the name
@@ -7158,10 +7167,12 @@ for (;; ptr++)
for (i++; i < cd->names_found; i++)
{
if (STRCMP_UC_UC(slot + IMM2_SIZE, cslot + IMM2_SIZE) != 0) break;
+
+
count++;
cslot += cd->name_entry_size;
}
-
+
if (count > 1)
{
if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;