com php-src: Fix overflow UB in range(): ext/standard/array.c

From: Date: Wed, 19 Jun 2019 13:09:00 +0000
Subject: com php-src: Fix overflow UB in range(): ext/standard/array.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-106894@lists.php.net to get a copy of this message
Commit: 4ae87f4bf964146d8da1deb64cf1b668f1103891 Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 19 Jun 2019 14:12:54 +0200 Parents: f26e77b05fe14e580e982c75887314b7fae7b777 Branches: PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4ae87f4bf964146d8da1deb64cf1b668f1103891 Log: Fix overflow UB in range() Changed paths: M ext/standard/array.c Diff: diff --git a/ext/standard/array.c b/ext/standard/array.c index 6ce48a1..b90f24a 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2717,7 +2717,7 @@ PHP_FUNCTION(array_fill_keys) } while (0) #define RANGE_CHECK_LONG_INIT_ARRAY(start, end) do { \ - zend_ulong __calc_size = (start - end) / lstep; \ + zend_ulong __calc_size = ((zend_ulong) start - end) / lstep; \ if (__calc_size >= HT_MAX_SIZE - 1) { \ php_error_docref(NULL, E_WARNING, "The supplied range exceeds the maximum array size: start=" ZEND_LONG_FMT " end=" ZEND_LONG_FMT, end, start); \ RETURN_FALSE; \ @@ -2887,7 +2887,7 @@ long_str: } if (low > high) { /* Negative steps */ - if ((zend_ulong)(low - high) < lstep) { + if ((zend_ulong)low - high < lstep) { err = 1; goto err; } @@ -2901,7 +2901,7 @@ long_str: } } ZEND_HASH_FILL_END(); } else if (high > low) { /* Positive steps */ - if ((zend_ulong)(high - low) < lstep) { + if ((zend_ulong)high - low < lstep) { err = 1; goto err; }

« previous php.cvs (#106894) next »