pcre/pcre-8.40-Make-pcretest-check-size-of-O-argument.patch

38 lines
1.0 KiB
Diff

From 312dd5d85714f73c247131b541405cf0bf24581b Mon Sep 17 00:00:00 2001
From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Thu, 23 Feb 2017 16:24:08 +0000
Subject: [PATCH] Make pcretest check size of \O argument.
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@1686 2f5784b3-3f2a-0410-8824-cb99058d5e15
Petr Písař: Ported to 8.40.
diff --git a/pcretest.c b/pcretest.c
index 797f99c..0a153be 100644
--- a/pcretest.c
+++ b/pcretest.c
@@ -4834,7 +4834,16 @@ while (!done)
continue;
case 'O':
- while(isdigit(*p)) n = n * 10 + *p++ - '0';
+ while(isdigit(*p))
+ {
+ if (n > (INT_MAX-10)/10) /* Hack to stop fuzzers */
+ {
+ printf("** \\O argument is too big\n");
+ yield = 1;
+ goto EXIT;
+ }
+ n = n * 10 + *p++ - '0';
+ }
if (n > size_offsets_max)
{
size_offsets_max = n;
--
2.7.4