diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2018-02-19 16:35:05 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2018-02-19 16:35:05 +0000 |
commit | 8dc7206187ef9e9486fb5f102b85400ae9795dd1 (patch) | |
tree | 8ea9ee26ffcc2440ba770c4eb91662812725d733 | |
parent | 4ffc344ddf6246bf8d19c94c58af0853ae6768a7 (diff) | |
download | pcre-8dc7206187ef9e9486fb5f102b85400ae9795dd1.tar.gz |
Fix POSIX API bug when REG_STARTEND is used with a non-zero starting offset and
there are unset groups within the matching group list.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1724 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | pcreposix.c | 6 |
2 files changed, 9 insertions, 4 deletions
@@ -4,7 +4,7 @@ ChangeLog for PCRE Note that the PCRE 8.xx series (PCRE1) is now in a bugfix-only state. All development is happening in the PCRE2 10.xx series. -Version 8.42 xx-xxx-2017 +Version 8.42 xx-xxx-2018 ------------------------ 1. Fixed a MIPS issue in the JIT compiler reported by Joshua Kinard. @@ -39,6 +39,11 @@ as the first character of a match. 8. Fix out-of-bounds read for partial matching of /./ against an empty string when the newline type is CRLF. +9. When matching using the the REG_STARTEND feature of the POSIX API with a +non-zero starting offset, unset capturing groups with lower numbers than a +group that did capture something were not being correctly returned as "unset" +(that is, with offset values of -1). + Version 8.41 05-July-2017 ------------------------- diff --git a/pcreposix.c b/pcreposix.c index 7b404a7..a76d6bf 100644 --- a/pcreposix.c +++ b/pcreposix.c @@ -6,7 +6,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel - Copyright (c) 1997-2017 University of Cambridge + Copyright (c) 1997-2018 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -389,8 +389,8 @@ if (rc >= 0) { for (i = 0; i < (size_t)rc; i++) { - pmatch[i].rm_so = ovector[i*2] + so; - pmatch[i].rm_eo = ovector[i*2+1] + so; + pmatch[i].rm_so = (ovector[i*2] < 0)? -1 : ovector[i*2] + so; + pmatch[i].rm_eo = (ovector[i*2+1] < 0)? -1: ovector[i*2+1] + so; } if (allocated_ovector) free(ovector); for (; i < nmatch; i++) pmatch[i].rm_so = pmatch[i].rm_eo = -1; |