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