Blame SOURCES/pcre-8.43-Check-the-size-of-the-number-after-C-as-it-is-read-i.patch

563aa7
From 3a9026509f9c1745f378595e55e5024361ad152d Mon Sep 17 00:00:00 2001
563aa7
From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
563aa7
Date: Mon, 10 Feb 2020 17:17:34 +0000
563aa7
Subject: [PATCH] Check the size of the number after (?C as it is read, in
563aa7
 order to avoid integer overflow.
563aa7
MIME-Version: 1.0
563aa7
Content-Type: text/plain; charset=UTF-8
563aa7
Content-Transfer-Encoding: 8bit
563aa7
563aa7
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1761 2f5784b3-3f2a-0410-8824-cb99058d5e15
563aa7
Petr Písař: Ported to 8.43.
563aa7
---
563aa7
 pcre_compile.c | 14 ++++++++------
563aa7
563aa7
diff --git a/pcre_compile.c b/pcre_compile.c
563aa7
index 079d30a..1e3d6c3 100644
563aa7
--- a/pcre_compile.c
563aa7
+++ b/pcre_compile.c
563aa7
@@ -6,7 +6,7 @@
563aa7
 and semantics are as close as possible to those of the Perl 5 language.
563aa7
 
563aa7
                        Written by Philip Hazel
563aa7
-           Copyright (c) 1997-2018 University of Cambridge
563aa7
+           Copyright (c) 1997-2020 University of Cambridge
563aa7
 
563aa7
 -----------------------------------------------------------------------------
563aa7
 Redistribution and use in source and binary forms, with or without
563aa7
@@ -7130,17 +7130,19 @@ for (;; ptr++)
563aa7
           int n = 0;
563aa7
           ptr++;
563aa7
           while(IS_DIGIT(*ptr))
563aa7
+            { 
563aa7
             n = n * 10 + *ptr++ - CHAR_0;
563aa7
+            if (n > 255)
563aa7
+              {
563aa7
+              *errorcodeptr = ERR38;
563aa7
+              goto FAILED;
563aa7
+              }
563aa7
+            } 
563aa7
           if (*ptr != CHAR_RIGHT_PARENTHESIS)
563aa7
             {
563aa7
             *errorcodeptr = ERR39;
563aa7
             goto FAILED;
563aa7
             }
563aa7
-          if (n > 255)
563aa7
-            {
563aa7
-            *errorcodeptr = ERR38;
563aa7
-            goto FAILED;
563aa7
-            }
563aa7
           *code++ = n;
563aa7
           PUT(code, 0, (int)(ptr - cd->start_pattern + 1)); /* Pattern offset */
563aa7
           PUT(code, LINK_SIZE, 0);                          /* Default length */
563aa7
-- 
563aa7
2.21.1
563aa7