From c7d7834a43a779203573580f707b630b055cf4c2 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Sun, 5 Aug 2001 14:40:14 +0000 Subject: [PATCH] Check that _php_math_basetolong result fits long (by request from Troels Arvin) --- ext/standard/math.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/standard/math.c b/ext/standard/math.c index bfdade04ca..89c529623c 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -752,6 +752,10 @@ _php_math_basetolong(zval *arg, int base) { if (digit >= base) { continue; } + if(!mult || digit > LONG_MAX/mult || num > LONG_MAX-mult*digit) { + php_error(E_WARNING, "base_to_long: number '%s' is too big to fit in long", s); + return LONG_MAX; + } num += mult * digit; } -- 2.50.1