diff --git a/pcre-8.43-Tidies-to-get-rid-of-sanitize-warnings-mostly-about-.patch b/pcre-8.43-Tidies-to-get-rid-of-sanitize-warnings-mostly-about-.patch new file mode 100644 index 0000000..a60ec9b --- /dev/null +++ b/pcre-8.43-Tidies-to-get-rid-of-sanitize-warnings-mostly-about-.patch @@ -0,0 +1,202 @@ +From be73d3747c3b2c0dab935279484bf96d55221106 Mon Sep 17 00:00:00 2001 +From: ph10 +Date: Tue, 11 Feb 2020 18:13:46 +0000 +Subject: [PATCH] Tidies to get rid of sanitize warnings (mostly about left + shifts). +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1762 2f5784b3-3f2a-0410-8824-cb99058d5e15 +Petr Písař: Ported to 8.43. +--- + pcre_compile.c | 16 ++++++++-------- + pcre_jit_compile.c | 6 +++--- + pcretest.c | 12 ++++++------ + testdata/testinput2 | 2 +- + testdata/testoutput2 | 3 +-- + +diff --git a/pcre_compile.c b/pcre_compile.c +index 1e3d6c3..32e5b91 100644 +--- a/pcre_compile.c ++++ b/pcre_compile.c +@@ -68,7 +68,7 @@ COMPILE_PCREx macro will already be appropriately set. */ + + /* Macro for setting individual bits in class bitmaps. */ + +-#define SETBIT(a,b) a[(b)/8] |= (1 << ((b)&7)) ++#define SETBIT(a,b) a[(b)/8] |= (1U << ((b)&7)) + + /* Maximum length value to check against when making sure that the integer that + holds the compiled pattern length does not overflow. We make it a bit less than +@@ -129,8 +129,8 @@ overrun before it actually does run off the end of the data block. */ + + /* Private flags added to firstchar and reqchar. */ + +-#define REQ_CASELESS (1 << 0) /* Indicates caselessness */ +-#define REQ_VARY (1 << 1) /* Reqchar followed non-literal item */ ++#define REQ_CASELESS (1U << 0) /* Indicates caselessness */ ++#define REQ_VARY (1U << 1) /* Reqchar followed non-literal item */ + /* Negative values for the firstchar and reqchar flags */ + #define REQ_UNSET (-2) + #define REQ_NONE (-1) +@@ -3611,7 +3611,7 @@ for(;;) + if (chr > 255) break; + class_bitset = (pcre_uint8 *) + ((list_ptr == list ? code : base_end) - list_ptr[2]); +- if ((class_bitset[chr >> 3] & (1 << (chr & 7))) != 0) return FALSE; ++ if ((class_bitset[chr >> 3] & (1U << (chr & 7))) != 0) return FALSE; + break; + + #if defined SUPPORT_UTF || !defined COMPILE_PCRE8 +@@ -7458,7 +7458,7 @@ for (;; ptr++) + { + open_capitem *oc; + recno = GET2(slot, 0); +- cd->backref_map |= (recno < 32)? (1 << recno) : 1; ++ cd->backref_map |= (recno < 32)? (1U << recno) : 1; + if (recno > cd->top_backref) cd->top_backref = recno; + + /* Check to see if this back reference is recursive, that it, it +@@ -8069,7 +8069,7 @@ for (;; ptr++) + item_hwm_offset = cd->hwm - cd->start_workspace; + *code++ = ((options & PCRE_CASELESS) != 0)? OP_REFI : OP_REF; + PUT2INC(code, 0, recno); +- cd->backref_map |= (recno < 32)? (1 << recno) : 1; ++ cd->backref_map |= (recno < 32)? (1U << recno) : 1; + if (recno > cd->top_backref) cd->top_backref = recno; + + /* Check to see if this back reference is recursive, that it, it +@@ -8682,7 +8682,7 @@ do { + 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, cd, atomcount)) return FALSE; + } + +@@ -8810,7 +8810,7 @@ do { + 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, cd, atomcount, inassert)) return FALSE; + } + +diff --git a/pcre_jit_compile.c b/pcre_jit_compile.c +index bc5f9c0..4dcf8fc 100644 +--- a/pcre_jit_compile.c ++++ b/pcre_jit_compile.c +@@ -3938,10 +3938,10 @@ static sljit_s32 character_to_int32(pcre_uchar chr) + sljit_s32 value = (sljit_s32)chr; + #if defined COMPILE_PCRE8 + #define SSE2_COMPARE_TYPE_INDEX 0 +-return (value << 24) | (value << 16) | (value << 8) | value; ++return ((unsigned int)value << 24) | ((unsigned int)value << 16) | ((unsigned int)value << 8) | (unsigned int)value; + #elif defined COMPILE_PCRE16 + #define SSE2_COMPARE_TYPE_INDEX 1 +-return (value << 16) | value; ++return ((unsigned int)value << 16) | value; + #elif defined COMPILE_PCRE32 + #define SSE2_COMPARE_TYPE_INDEX 2 + return value; +@@ -8507,7 +8507,7 @@ if (opcode == OP_ONCE) + /* We temporarily encode the needs_control_head in the lowest bit. + Note: on the target architectures of SLJIT the ((x << 1) >> 1) returns + the same value for small signed numbers (including negative numbers). */ +- BACKTRACK_AS(bracket_backtrack)->u.framesize = (BACKTRACK_AS(bracket_backtrack)->u.framesize << 1) | (needs_control_head ? 1 : 0); ++ BACKTRACK_AS(bracket_backtrack)->u.framesize = ((unsigned int)BACKTRACK_AS(bracket_backtrack)->u.framesize << 1) | (needs_control_head ? 1 : 0); + } + return cc + repeat_length; + } +diff --git a/pcretest.c b/pcretest.c +index f130303..c1ee128 100644 +--- a/pcretest.c ++++ b/pcretest.c +@@ -500,7 +500,7 @@ enum { + #if (defined (SUPPORT_PCRE8) + defined (SUPPORT_PCRE16) + \ + defined (SUPPORT_PCRE32)) >= 2 + +-#define CHAR_SIZE (1 << pcre_mode) ++#define CHAR_SIZE (1U << pcre_mode) + + /* There doesn't seem to be an easy way of writing these macros that can cope + with the 3 pairs of bit sizes plus all three bit sizes. So just handle all the +@@ -4443,7 +4443,7 @@ while (!done) + + /* If there is study data, write it. */ + +- if (extra != NULL) ++ if (extra != NULL && (extra->flags & PCRE_EXTRA_STUDY_DATA) != 0) + { + if (fwrite(extra->study_data, 1, true_study_size, f) < + true_study_size) +@@ -4735,7 +4735,7 @@ while (!done) + if (isdigit(*p)) /* Set copy string */ + { + while(isdigit(*p)) n = n * 10 + *p++ - '0'; +- copystrings |= 1 << n; ++ copystrings |= 1U << n; + } + else if (isalnum(*p)) + { +@@ -4798,7 +4798,7 @@ while (!done) + if (isdigit(*p)) + { + while(isdigit(*p)) n = n * 10 + *p++ - '0'; +- getstrings |= 1 << n; ++ getstrings |= 1U << n; + } + else if (isalnum(*p)) + { +@@ -5335,7 +5335,7 @@ while (!done) + + for (i = 0; i < 32; i++) + { +- if ((copystrings & (1 << i)) != 0) ++ if ((copystrings & (1U << i)) != 0) + { + int rc; + char copybuffer[256]; +@@ -5400,7 +5400,7 @@ while (!done) + + for (i = 0; i < 32; i++) + { +- if ((getstrings & (1 << i)) != 0) ++ if ((getstrings & (1U << i)) != 0) + { + int rc; + const char *substring; +diff --git a/testdata/testinput2 b/testdata/testinput2 +index 3528de1..53c9825 100644 +--- a/testdata/testinput2 ++++ b/testdata/testinput2 +@@ -1380,7 +1380,7 @@ + 1X + 123456\P + +-//KF>testsavedregex ++//S-KF>testsavedregex + + /abc/IS>testsavedregex + testsavedregex ++//S-KF>testsavedregex + Compiled pattern written to testsavedregex +-Study data written to testsavedregex + + /abc/IS>testsavedregex + Capturing subpattern count = 0 +-- +2.21.1 + diff --git a/pcre.spec b/pcre.spec index e170c8a..6e8b0b9 100644 --- a/pcre.spec +++ b/pcre.spec @@ -49,6 +49,9 @@ Patch5: pcre-8.43-Minor-fix-to-avoid-sanitizer-complaint-in-POSIX-wrap.patch # Fix an integer overflow when parsing numbers after "(?C", # upstream bug #2463, in upstream after 8.43 Patch6: pcre-8.43-Check-the-size-of-the-number-after-C-as-it-is-read-i.patch +# Fix shifting integers bits and a NULL pointer dereferce in pcretest tool, +# in upstream after 8.43 +Patch7: pcre-8.43-Tidies-to-get-rid-of-sanitize-warnings-mostly-about-.patch BuildRequires: readline-devel BuildRequires: autoconf BuildRequires: automake @@ -137,6 +140,7 @@ Utilities demonstrating PCRE capabilities like pcregrep or pcretest. %patch4 -p1 %patch5 -p1 %patch6 -p1 +%patch7 -p1 # Because of rpath patch libtoolize --copy --force autoreconf -vif @@ -240,6 +244,7 @@ make %{?_smp_mflags} check VERBOSE=yes - Make erroroffset initializion in a POSIX wrapper thread-safe (upstream bug #2447) - Fix an integer overflow when parsing numbers after "(?C" (upstream bug #2463) +- Fix shifting integers bits and a NULL pointer dereferce in pcretest tool * Fri Jul 26 2019 Fedora Release Engineering - 8.43-2.1 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild