summaryrefslogtreecommitdiff
path: root/pcre_exec.c
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2010-11-06 17:10:00 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2010-11-06 17:10:00 +0000
commit816309b6a76b4454b9e24dcd47d83960c92ad68b (patch)
treeb5f9918ce2821f54a64ad1cc9a2ccc72e50878bb /pcre_exec.c
parented44c1dfe4d6a49f32fbb2927444306ccf4e0acb (diff)
downloadpcre-816309b6a76b4454b9e24dcd47d83960c92ad68b.tar.gz
Test for ridiculous values of starting offsets; tidy UTF-8 code.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@567 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcre_exec.c')
-rw-r--r--pcre_exec.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/pcre_exec.c b/pcre_exec.c
index b1d895d..c4618a6 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -5634,6 +5634,7 @@ if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;
if (re == NULL || subject == NULL ||
(offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;
if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;
+if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;
/* This information is for finding all the numbers associated with a given
name, for condition testing. */
@@ -5804,12 +5805,8 @@ if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0)
return PCRE_ERROR_BADUTF8;
if (start_offset > 0 && start_offset < length)
{
- int tb = ((USPTR)subject)[start_offset];
- if (tb > 127)
- {
- tb &= 0xc0;
- if (tb != 0 && tb != 0xc0) return PCRE_ERROR_BADUTF8_OFFSET;
- }
+ int tb = ((USPTR)subject)[start_offset] & 0xc0;
+ if (tb == 0x80) return PCRE_ERROR_BADUTF8_OFFSET;
}
}
#endif