diff --git a/ChangeLog b/ChangeLog index 57c8999..161b4e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -132,6 +132,8 @@ a warning for "fileno" unless -std=gnu99 us used. 33. A lookbehind assertion within a set of mutually recursive subpatterns could provoke a buffer overflow. This bug was discovered by the LLVM fuzzer. +34. Give an error for an empty subpattern name such as (?''). + Version 10.10 06-March-2015 --------------------------- diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index 07b23c8..7719d88 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -5814,13 +5814,19 @@ for (;; ptr++) { named_group *ng; uint32_t number = cb->bracount + 1; - + if (*ptr != (PCRE2_UCHAR)terminator) { *errorcodeptr = ERR42; goto FAILED; } + if (namelen == 0) + { + *errorcodeptr = ERR62; + goto FAILED; + } + if (cb->names_found >= MAX_NAME_COUNT) { *errorcodeptr = ERR49; diff --git a/testdata/testinput2 b/testdata/testinput2 index a00a3d8..4badd3f 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -4298,14 +4298,16 @@ a random value. /Ix /\V\x85\9*+((?2)\3++()2)*:2/ -/(((?(R)){0,2}) (?''((?'R')((?'R')))))/dupnames +/(((?(R)){0,2}) (?'x'((?'R')((?'R')))))/dupnames -/(((?(X)){0,2}) (?''((?'X')((?'X')))))/dupnames +/(((?(X)){0,2}) (?'x'((?'X')((?'X')))))/dupnames -/(((?(R)){0,2}) (?''((?'X')((?'R')))))/ +/(((?(R)){0,2}) (?'x'((?'X')((?'R')))))/ "(?J)(?'d'(?'d'\g{d}))" "(?=!((?2)(?))({8(?<=(?1){29}8bbbb\x16\xd\xc6^($(\xa9H4){4}h}?1)B))\x15')" +/A(?'')Z/ + # End of testinput2 diff --git a/testdata/testinput5 b/testdata/testinput5 index 9ab5f41..7e2ba45 100644 --- a/testdata/testinput5 +++ b/testdata/testinput5 @@ -1647,8 +1647,8 @@ /(?<=\K\x{17f})/altglobal,utf,aftertext \x{17f}\x{17f}\x{17f}\x{17f}\x{17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{x}\x11\g{d}\x81\|$((?'X'\'X'(?'W''\x92()'9'\x83*))\xba*\!?^ <){)':;\xcc4'\xd1'(?'X'28))?-%--\x95$9*\4'|\xd1((''e\x94*$9:)*#(?'R')3)\x7?('P\xed')\\x16:;()\x1e\x10*:(?)\xd1+0!~:(?)'d'E:yD!\s(?'R'\x1e;\x10:U))|'\x9g!\xb0*){)\\x16:;()\x1e\x10\x87*:(?)\xd1+!~:(?)'}'\d'E:yD!\s(?'R'\x1e;\x10:U))|'))|)g!\xb0*R+9{29+)#(?'P'})*?pS\{3,}\x85,{0,}l{*UTF)(\xe{7}){3722,{9,}d{2,?|))|{)\(A?&d}}{\xa,}2}){3,}7,l{)22}(,}l:7{2,4}}29\x19+)#?'P'})*v?))\x5" -/$(&.+[\p{Me}].\s\xdcC*?(?())(?)\xd1+!~:(?)''(d'E:yD!\s(?'R'\x1e;\x10:U))|')g!\xb0*){29+))#(?'P'})*?/ +/$(&.+[\p{Me}].\s\xdcC*?(?())(?)\xd1+!~:(?)''(d'E:yD!\s(?'R'\x1e;\x10:U))|')g!\xb0*){29+))#(?'P'})*?/ # End of testinput5 diff --git a/testdata/testoutput2 b/testdata/testoutput2 index 51a04a1..a98e277 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -14397,15 +14397,18 @@ Failed: error 115 at offset 22: reference to non-existent subpattern /\V\x85\9*+((?2)\3++()2)*:2/ Failed: error 115 at offset 26: reference to non-existent subpattern -/(((?(R)){0,2}) (?''((?'R')((?'R')))))/dupnames +/(((?(R)){0,2}) (?'x'((?'R')((?'R')))))/dupnames -/(((?(X)){0,2}) (?''((?'X')((?'X')))))/dupnames +/(((?(X)){0,2}) (?'x'((?'X')((?'X')))))/dupnames -/(((?(R)){0,2}) (?''((?'X')((?'R')))))/ +/(((?(R)){0,2}) (?'x'((?'X')((?'R')))))/ "(?J)(?'d'(?'d'\g{d}))" "(?=!((?2)(?))({8(?<=(?1){29}8bbbb\x16\xd\xc6^($(\xa9H4){4}h}?1)B))\x15')" Failed: error 125 at offset 72: lookbehind assertion is not fixed length +/A(?'')Z/ +Failed: error 162 at offset 4: subpattern name expected + # End of testinput2 diff --git a/testdata/testoutput5 b/testdata/testoutput5 index d85f909..a99c12b 100644 --- a/testdata/testoutput5 +++ b/testdata/testoutput5 @@ -4045,9 +4045,9 @@ Failed: error 140 at offset 11: recursion could loop indefinitely 0: \x{17f} 0+ -"\xa\xf<(.\pZ*\P{Xwd}+^\xa8\3'3yq.::?(?J:()\xd1+!~:3'(8?:)':(?'d'(?'d'^u]!.+.+\\A\Ah(n+?9){7}+\K;(?''u'(?'c'(?'z'(?\xb::\xf0'|\xd3(\xae?'w(z\x8?P>l)\x8?P>a)'\H\R\xd1+!!~:3'(?:h$N{26875}\W+?\\=D{2}\x89(?i:Uy0\N({2\xa(\v\x85*){y*\A(()\p{L}+?\P{^Xan}'+?\xff\+pS\?|).{;y*\A(()\p{L}+?\8}\d?1(|)(/1){7}.+[Lp{Me}].\s\xdcC*?(?())(?))(?\g{d});\g{x}\x11\g{d}\x81\|$((?''\'X'(?'W''\x92()'9'\x83*))\xba*\!?^ <){)':;\xcc4'\xd1'(?''28))?-%--\x95$9*\4'|\xd1((''e\x94*$9:)*#(?'R')3)\x7?('P\xed')\\x16:;()\x1e\x10*:(?)\xd1+0!~:(?)'d'E:yD!\s(?'R'\x1e;\x10:U))|'\x9g!\xb0*){)\\x16:;()\x1e\x10\x87*:(?)\xd1+!~:(?)'}'\d'E:yD!\s(?'R'\x1e;\x10:U))|'))|)g!\xb0*R+9{29+)#(?'P'})*?pS\{3,}\x85,{0,}l{*UTF)(\xe{7}){3722,{9,}d{2,?|))|{)\(A?&d}}{\xa,}2}){3,}7,l{)22}(,}l:7{2,4}}29\x19+)#?'P'})*v?))\x5" -Failed: error 122 at offset 1221: unmatched closing parenthesis +"\xa\xf<(.\pZ*\P{Xwd}+^\xa8\3'3yq.::?(?J:()\xd1+!~:3'(8?:)':(?'d'(?'d'^u]!.+.+\\A\Ah(n+?9){7}+\K;(?'X'u'(?'c'(?'z'(?\xb::\xf0'|\xd3(\xae?'w(z\x8?P>l)\x8?P>a)'\H\R\xd1+!!~:3'(?:h$N{26875}\W+?\\=D{2}\x89(?i:Uy0\N({2\xa(\v\x85*){y*\A(()\p{L}+?\P{^Xan}'+?\xff\+pS\?|).{;y*\A(()\p{L}+?\8}\d?1(|)(/1){7}.+[Lp{Me}].\s\xdcC*?(?())(?))(?\g{d});\g{x}\x11\g{d}\x81\|$((?'X'\'X'(?'W''\x92()'9'\x83*))\xba*\!?^ <){)':;\xcc4'\xd1'(?'X'28))?-%--\x95$9*\4'|\xd1((''e\x94*$9:)*#(?'R')3)\x7?('P\xed')\\x16:;()\x1e\x10*:(?)\xd1+0!~:(?)'d'E:yD!\s(?'R'\x1e;\x10:U))|'\x9g!\xb0*){)\\x16:;()\x1e\x10\x87*:(?)\xd1+!~:(?)'}'\d'E:yD!\s(?'R'\x1e;\x10:U))|'))|)g!\xb0*R+9{29+)#(?'P'})*?pS\{3,}\x85,{0,}l{*UTF)(\xe{7}){3722,{9,}d{2,?|))|{)\(A?&d}}{\xa,}2}){3,}7,l{)22}(,}l:7{2,4}}29\x19+)#?'P'})*v?))\x5" +Failed: error 122 at offset 1227: unmatched closing parenthesis -/$(&.+[\p{Me}].\s\xdcC*?(?())(?)\xd1+!~:(?)''(d'E:yD!\s(?'R'\x1e;\x10:U))|')g!\xb0*){29+))#(?'P'})*?/ +/$(&.+[\p{Me}].\s\xdcC*?(?())(?)\xd1+!~:(?)''(d'E:yD!\s(?'R'\x1e;\x10:U))|')g!\xb0*){29+))#(?'P'})*?/ # End of testinput5