04bfb0
From a0148bb8496444302b087bc0ffcf8dad42f8e475 Mon Sep 17 00:00:00 2001
04bfb0
From: Tony Cook <tony@develop-help.com>
04bfb0
Date: Mon, 11 Nov 2019 14:43:42 +1100
04bfb0
Subject: [PATCH] handle s being updated without len being updated
04bfb0
MIME-Version: 1.0
04bfb0
Content-Type: text/plain; charset=UTF-8
04bfb0
Content-Transfer-Encoding: 8bit
04bfb0
04bfb0
fix #17279
04bfb0
04bfb0
Petr Písař: Ported to 5.30.1 from
04bfb0
e56dfd967ce460481a9922d14e931b438548093d.
04bfb0
04bfb0
Signed-off-by: Petr Písař <ppisar@redhat.com>
04bfb0
---
04bfb0
 numeric.c           | 2 +-
04bfb0
 t/lib/croak/regcomp | 4 ++++
04bfb0
 2 files changed, 5 insertions(+), 1 deletion(-)
04bfb0
04bfb0
diff --git a/numeric.c b/numeric.c
04bfb0
index d6ce53e..35adebe 100644
04bfb0
--- a/numeric.c
04bfb0
+++ b/numeric.c
04bfb0
@@ -1552,7 +1552,7 @@ Perl_my_atof3(pTHX_ const char* orig, NV* value, const STRLEN len)
04bfb0
         /* strtold() accepts 0x-prefixed hex and in POSIX implementations,
04bfb0
            0b-prefixed binary numbers, which is backward incompatible
04bfb0
         */
04bfb0
-        if ((len == 0 || len >= 2) && *s == '0' &&
04bfb0
+        if ((len == 0 || len - (s-orig) >= 2) && *s == '0' &&
04bfb0
             (isALPHA_FOLD_EQ(s[1], 'x') || isALPHA_FOLD_EQ(s[1], 'b'))) {
04bfb0
             *value = 0;
04bfb0
             return (char *)s+1;
04bfb0
diff --git a/t/lib/croak/regcomp b/t/lib/croak/regcomp
04bfb0
index 0ba705e..c0c2710 100644
04bfb0
--- a/t/lib/croak/regcomp
04bfb0
+++ b/t/lib/croak/regcomp
04bfb0
@@ -70,3 +70,7 @@ qr/((a))/;
04bfb0
 EXPECT
04bfb0
 Too many nested open parens in regex; marked by <-- HERE in m/(( <-- HERE a))/ at - line 3.
04bfb0
 ########
04bfb0
+# NAME numeric parsing buffer overflow in numeric.c
04bfb0
+0=~/\p{nV:-0}/
04bfb0
+EXPECT
04bfb0
+Can't find Unicode property definition "nV:-0" in regex; marked by <-- HERE in m/\p{nV:-0} <-- HERE / at - line 1.
04bfb0
-- 
04bfb0
2.21.0
04bfb0