chiark / gitweb /
upstream patch fixing CVE-2020-14155
authorMatthew Vernon <matthew@debian.org>
Thu, 18 Jun 2020 18:32:51 +0000 (19:32 +0100)
committerMatthew Vernon <matthew@debian.org>
Thu, 18 Jun 2020 18:32:51 +0000 (19:32 +0100)
This checks the size of the number after (?C as it is read, in order
to avoid integer overflow.

pcre_compile.c

index 7cd395012304e588a6ef3c7167e17111ba69829d..c7422271876305caa583774d1a534ac0ffe590cf 100644 (file)
@@ -7086,17 +7086,19 @@ for (;; ptr++)
           int n = 0;
           ptr++;
           while(IS_DIGIT(*ptr))
+            { 
             n = n * 10 + *ptr++ - CHAR_0;
+            if (n > 255)
+              {
+              *errorcodeptr = ERR38;
+              goto FAILED;
+              }
+            } 
           if (*ptr != CHAR_RIGHT_PARENTHESIS)
             {
             *errorcodeptr = ERR39;
             goto FAILED;
             }
-          if (n > 255)
-            {
-            *errorcodeptr = ERR38;
-            goto FAILED;
-            }
           *code++ = n;
           PUT(code, 0, (int)(ptr - cd->start_pattern + 1)); /* Pattern offset */
           PUT(code, LINK_SIZE, 0);                          /* Default length */