[Pcre-svn] [267] code/trunk: Fix sanitize=undefined warnings…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [267] code/trunk: Fix sanitize=undefined warnings for left shifts of 31.
Revision: 267
          http://www.exim.org/viewvc/pcre2?view=rev&revision=267
Author:   ph10
Date:     2015-05-16 17:02:46 +0100 (Sat, 16 May 2015)
Log Message:
-----------
Fix sanitize=undefined warnings for left shifts of 31.


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


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2015-05-16 11:01:48 UTC (rev 266)
+++ code/trunk/ChangeLog    2015-05-16 16:02:46 UTC (rev 267)
@@ -123,7 +123,10 @@
 current group, for example in this pattern: /(?|(\k'Pm')|(?'Pm'))/, caused a
 buffer overflow at compile time. This bug was discovered by the LLVM fuzzer.


+31. Fix -fsanitize=undefined warnings for left shifts of 1 by 31 (it treats 1
+as an int; fixed by writing it as 1u).

+
Version 10.10 06-March-2015
---------------------------


Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c    2015-05-16 11:01:48 UTC (rev 266)
+++ code/trunk/src/pcre2_compile.c    2015-05-16 16:02:46 UTC (rev 267)
@@ -6057,7 +6057,7 @@
               {
               open_capitem *oc;
               recno = GET2(slot, 0);
-              cb->backref_map |= (recno < 32)? (1 << recno) : 1;
+              cb->backref_map |= (recno < 32)? (1u << recno) : 1;
               if ((uint32_t)recno > cb->top_backref) cb->top_backref = recno;


               /* Check to see if this back reference is recursive, that is, it
@@ -6686,7 +6686,7 @@
         item_hwm_offset = cb->hwm - cb->start_workspace;
         *code++ = ((options & PCRE2_CASELESS) != 0)? OP_REFI : OP_REF;
         PUT2INC(code, 0, recno);
-        cb->backref_map |= (recno < 32)? (1 << recno) : 1;
+        cb->backref_map |= (recno < 32)? (1u << recno) : 1;
         if ((uint32_t)recno > cb->top_backref) cb->top_backref = recno;


         /* Check to see if this back reference is recursive, that it, it
@@ -7302,7 +7302,7 @@
             op == OP_SCBRA || op == OP_SCBRAPOS)
      {
      int n = GET2(scode, 1+LINK_SIZE);
-     int new_map = bracket_map | ((n < 32)? (1 << n) : 1);
+     int new_map = bracket_map | ((n < 32)? (1u << n) : 1);
      if (!is_anchored(scode, new_map, cb, atomcount)) return FALSE;
      }


@@ -7426,7 +7426,7 @@
             op == OP_SCBRA || op == OP_SCBRAPOS)
      {
      int n = GET2(scode, 1+LINK_SIZE);
-     int new_map = bracket_map | ((n < 32)? (1 << n) : 1);
+     int new_map = bracket_map | ((n < 32)? (1u << n) : 1);
      if (!is_startline(scode, new_map, cb, atomcount)) return FALSE;
      }