Set error offset zero for early errors in pcre2_pattern_convert().

This commit is contained in:
Philip.Hazel 2018-03-04 15:13:37 +00:00
parent 26edb6cb43
commit a7b2b6ff64
2 changed files with 12 additions and 3 deletions

View File

@ -38,6 +38,9 @@ dummies force 32-bit alignment and this ensures that the structure is a
multiple of PCRE2_SIZE, a requirement that is tested at compile time. In other multiple of PCRE2_SIZE, a requirement that is tested at compile time. In other
architectures, alignment requirements take care of this automatically. architectures, alignment requirements take care of this automatically.
9. When returning an error from pcre2_pattern_convert(), ensure the error
offset is set zero for early errors.
Version 10.31 12-February-2018 Version 10.31 12-February-2018
------------------------------ ------------------------------

View File

@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2016-2017 University of Cambridge New API code Copyright (c) 2016-2018 University of Cambridge
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
@ -1066,6 +1066,7 @@ BOOL utf = (options & PCRE2_CONVERT_UTF) != 0;
uint32_t pattype = options & TYPE_OPTIONS; uint32_t pattype = options & TYPE_OPTIONS;
if (pattern == NULL || bufflenptr == NULL) return PCRE2_ERROR_NULL; if (pattern == NULL || bufflenptr == NULL) return PCRE2_ERROR_NULL;
if ((options & ~ALL_OPTIONS) != 0 || /* Undefined bit set */ if ((options & ~ALL_OPTIONS) != 0 || /* Undefined bit set */
(pattype & (~pattype+1)) != pattype || /* More than one type set */ (pattype & (~pattype+1)) != pattype || /* More than one type set */
pattype == 0) /* No type set */ pattype == 0) /* No type set */
@ -1081,7 +1082,11 @@ if (ccontext == NULL) ccontext =
/* Check UTF if required. */ /* Check UTF if required. */
#ifndef SUPPORT_UNICODE #ifndef SUPPORT_UNICODE
if (utf) return PCRE2_ERROR_UNICODE_NOT_SUPPORTED; if (utf)
{
*bufflenptr = 0; /* Error offset */
return PCRE2_ERROR_UNICODE_NOT_SUPPORTED;
}
#else #else
if (utf && (options & PCRE2_CONVERT_NO_UTF_CHECK) == 0) if (utf && (options & PCRE2_CONVERT_NO_UTF_CHECK) == 0)
{ {
@ -1126,6 +1131,7 @@ for (i = 0; i < 2; i++)
break; break;
default: default:
*bufflenptr = 0; /* Error offset */
return PCRE2_ERROR_INTERNAL; return PCRE2_ERROR_INTERNAL;
} }