[Pcre-svn] [926] code/trunk: Set error offset zero for early…

Páxina inicial
Borrar esta mensaxe
Autor: Subversion repository
Data:  
Para: pcre-svn
Asunto: [Pcre-svn] [926] code/trunk: Set error offset zero for early errors in pcre2_pattern_convert().
Revision: 926
          http://www.exim.org/viewvc/pcre2?view=rev&revision=926
Author:   ph10
Date:     2018-03-04 15:13:37 +0000 (Sun, 04 Mar 2018)
Log Message:
-----------
Set error offset zero for early errors in pcre2_pattern_convert().


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2_convert.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2018-02-28 09:03:12 UTC (rev 925)
+++ code/trunk/ChangeLog    2018-03-04 15:13:37 UTC (rev 926)
@@ -38,7 +38,10 @@
 multiple of PCRE2_SIZE, a requirement that is tested at compile time. In other
 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
------------------------------


Modified: code/trunk/src/pcre2_convert.c
===================================================================
--- code/trunk/src/pcre2_convert.c    2018-02-28 09:03:12 UTC (rev 925)
+++ code/trunk/src/pcre2_convert.c    2018-03-04 15:13:37 UTC (rev 926)
@@ -7,7 +7,7 @@


                        Written by Philip Hazel
      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
@@ -1066,11 +1066,12 @@
uint32_t pattype = options & TYPE_OPTIONS;

 if (pattern == NULL || bufflenptr == NULL) return PCRE2_ERROR_NULL;
+
 if ((options & ~ALL_OPTIONS) != 0 ||        /* Undefined bit set */
     (pattype & (~pattype+1)) != pattype ||  /* More than one type set */
     pattype == 0)                           /* No type set */
   {
-  *bufflenptr = 0;  /* Error offset */
+  *bufflenptr = 0;                          /* Error offset */
   return PCRE2_ERROR_BADOPTION;
   }


@@ -1081,7 +1082,11 @@
/* Check UTF if required. */

 #ifndef SUPPORT_UNICODE
-if (utf) return PCRE2_ERROR_UNICODE_NOT_SUPPORTED;
+if (utf)
+  {
+  *bufflenptr = 0;  /* Error offset */
+  return PCRE2_ERROR_UNICODE_NOT_SUPPORTED;
+  }
 #else
 if (utf && (options & PCRE2_CONVERT_NO_UTF_CHECK) == 0)
   {
@@ -1126,6 +1131,7 @@
     break;


     default:
+    *bufflenptr = 0;  /* Error offset */
     return PCRE2_ERROR_INTERNAL;
     }