Skip to content

Commit 3f0cab5

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
2 parents 7a81505 + e65adc9 commit 3f0cab5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Negative parse_iv2 edge cases
3+
--FILE--
4+
<?php
5+
6+
var_dump(unserialize('i:-9223372036854775808;'));
7+
var_dump(unserialize('i:-0;'));
8+
9+
?>
10+
--EXPECT--
11+
int(-9223372036854775808)
12+
int(0)

ext/standard/var_unserializer.re

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,12 @@ static inline zend_long parse_iv2(const unsigned char *p, const unsigned char **
400400
|| (SIZEOF_ZEND_LONG == 4
401401
&& UNEXPECTED(p - start == MAX_LENGTH_OF_LONG - 1)
402402
&& UNEXPECTED(*start > '2'))
403-
|| UNEXPECTED(result - neg > ZEND_LONG_MAX)) {
403+
|| UNEXPECTED(result > ZEND_LONG_MAX + neg)) {
404404
php_error_docref(NULL, E_WARNING, "Numerical result out of range");
405405
return (!neg) ? ZEND_LONG_MAX : ZEND_LONG_MIN;
406406
}
407407

408-
return (!neg) ? (zend_long)result : -(zend_long)result;
408+
return (zend_long) ((!neg) ? result : -result);
409409
}
410410

411411
static inline zend_long parse_iv(const unsigned char *p)

0 commit comments

Comments
 (0)