From: Dmitry Stogov Date: Mon, 24 Dec 2007 18:10:20 +0000 (+0000) Subject: Additional fix for bug #42868 X-Git-Tag: RELEASE_2_0_0a1~1113 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0c75772f681fc6e13bae08723e8625f879501c0d;p=php Additional fix for bug #42868 --- diff --git a/Zend/tests/int_overflow_64bit.phpt b/Zend/tests/int_overflow_64bit.phpt index 306fbae602..769b17926e 100644 --- a/Zend/tests/int_overflow_64bit.phpt +++ b/Zend/tests/int_overflow_64bit.phpt @@ -6,11 +6,13 @@ testing integer overflow (64bit) --EXPECTF-- -int(-9223372036854775808) -int(-9223372036854775808) +int(9223372036854775807) +int(9223372036854775807) +int(9223372036854775807) +int(9223372036854775807) int(-9223372036854775808) int(-9223372036854775808) int(-9223372036854775808) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 6f22c20165..3eff4f2b2d 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -243,34 +243,35 @@ ZEND_API int convert_scalar_to_number(zval *op TSRMLS_DC) /* {{{ */ #define MAX_UNSIGNED_INT ((double) LONG_MAX * 2) + 1 #ifdef _WIN64 # define DVAL_TO_LVAL(d, l) \ - if ((d) > LONG_MAX) { \ - if ((d) > MAX_UNSIGNED_INT) { \ - (l) = LONG_MAX; \ - } else { \ - (l) = (long)(unsigned long)(__int64) (d); \ - } \ - } else { \ - if((d) < LONG_MIN) { \ - (l) = LONG_MIN; \ - } else { \ - (l) = (long) (d); \ - } \ - } + if ((d) > LONG_MAX) { \ + (l) = (long)(unsigned long)(__int64) (d); \ + } else { \ + (l) = (long) (d); \ + } +#elif !defined(_WIN64) && __WORDSIZE == 64 +# define DVAL_TO_LVAL(d, l) \ + if ((d) >= LONG_MAX) { \ + (l) = LONG_MAX; \ + } else if ((d) <= LONG_MIN) { \ + (l) = LONG_MIN; \ + } else {\ + (l) = (long) (d); \ + } #else # define DVAL_TO_LVAL(d, l) \ - if ((d) > LONG_MAX) { \ - if ((d) > MAX_UNSIGNED_INT) { \ - (l) = LONG_MAX; \ - } else { \ - (l) = (unsigned long) (d); \ - } \ - } else { \ - if((d) < LONG_MIN) { \ - (l) = LONG_MIN; \ - } else { \ - (l) = (long) (d); \ - } \ - } + if ((d) > LONG_MAX) { \ + if ((d) > MAX_UNSIGNED_INT) { \ + (l) = LONG_MAX; \ + } else { \ + (l) = (unsigned long) (d); \ + } \ + } else { \ + if((d) < LONG_MIN) { \ + (l) = LONG_MIN; \ + } else { \ + (l) = (long) (d); \ + } \ + } #endif /* }}} */ diff --git a/ext/standard/string.c b/ext/standard/string.c index 78efe3f18b..6074a59a32 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3339,7 +3339,7 @@ PHP_FUNCTION(chunk_split) zstr result; char *end = "\r\n"; UChar u_end[3] = { 0x0d, 0x0a, 0x0 }; - int chunklen = 76; + long chunklen = 76; int result_len; zend_uchar str_type; diff --git a/ext/standard/tests/strings/chunk_split_error.phpt b/ext/standard/tests/strings/chunk_split_error.phpt index 9a0819c732..9313b65b5b 100644 --- a/ext/standard/tests/strings/chunk_split_error.phpt +++ b/ext/standard/tests/strings/chunk_split_error.phpt @@ -19,7 +19,7 @@ echo "*** Testing chunk_split() : error conditions ***\n"; echo "-- Testing chunk_split() function with Zero arguments --"; var_dump( chunk_split() ); -//Test chunk_split with one more than the expected number of arguments +// With one more than the expected number of arguments $str = 'Testing chunk_split'; $chunklen = 5; $ending = '***'; @@ -38,12 +38,3 @@ NULL Warning: chunk_split() expects at most 3 parameters, 4 given in %s on line %d NULL Done ---UEXPECTF-- -*** Testing chunk_split() : error conditions *** --- Testing chunk_split() function with Zero arguments -- -Warning: chunk_split() expects at least 1 parameter, 0 given in %s on line %d -NULL --- Testing chunk_split() function with more than expected no. of arguments -- -Warning: chunk_split() expects at most 3 parameters, 4 given in %s on line %d -NULL -Done diff --git a/ext/standard/tests/strings/chunk_split_variation5.phpt b/ext/standard/tests/strings/chunk_split_variation5.phpt index 170f9e1364..f8e84a9ca4 100644 Binary files a/ext/standard/tests/strings/chunk_split_variation5.phpt and b/ext/standard/tests/strings/chunk_split_variation5.phpt differ diff --git a/ext/standard/tests/strings/chunk_split_variation8.phpt b/ext/standard/tests/strings/chunk_split_variation8.phpt index c3ceeceb4c..2d82c4945c 100644 --- a/ext/standard/tests/strings/chunk_split_variation8.phpt +++ b/ext/standard/tests/strings/chunk_split_variation8.phpt @@ -1,5 +1,5 @@ --TEST-- -Test chunk_split() function : usage variations - different integer values for 'chunklen' with heredoc string as 'str' +Test chunk_split() function : usage variations - different integer values for 'chunklen' with heredoc string as 'str'(Bug#42796) --FILE-- Roy's height > Sam's height. 13 < 15. 1111 & 0000 -- Iteration 6 -- -Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d +Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 7 -- -Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d +Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 8 -- -Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d +Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 9 -- -Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d +Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 10 -- -Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d +Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %s on line %d NULL -- Iteration 11 -- @@ -252,27 +252,27 @@ unicode(114) "Roy's height > Sam's height. 13 < 15. 1111 & 0000 -- Iteration 17 -- -Warning: htmlspecialchars_decode() expects parameter 2 to be long, Unicode string given in %shtmlspecialchars_decode_variation2.php on line %d +Warning: htmlspecialchars_decode() expects parameter 2 to be long, Unicode string given in %s on line %d NULL -- Iteration 18 -- -Warning: htmlspecialchars_decode() expects parameter 2 to be long, Unicode string given in %shtmlspecialchars_decode_variation2.php on line %d +Warning: htmlspecialchars_decode() expects parameter 2 to be long, Unicode string given in %s on line %d NULL -- Iteration 19 -- -Warning: htmlspecialchars_decode() expects parameter 2 to be long, Unicode string given in %shtmlspecialchars_decode_variation2.php on line %d +Warning: htmlspecialchars_decode() expects parameter 2 to be long, Unicode string given in %s on line %d NULL -- Iteration 20 -- -Warning: htmlspecialchars_decode() expects parameter 2 to be long, Unicode string given in %shtmlspecialchars_decode_variation2.php on line %d +Warning: htmlspecialchars_decode() expects parameter 2 to be long, Unicode string given in %s on line %d NULL -- Iteration 21 -- -Warning: htmlspecialchars_decode() expects parameter 2 to be long, object given in %shtmlspecialchars_decode_variation2.php on line %d +Warning: htmlspecialchars_decode() expects parameter 2 to be long, object given in %s on line %d NULL -- Iteration 22 -- @@ -283,7 +283,6 @@ unicode(114) "Roy's height > Sam's height. 13 < 15. 1111 & 0000 -- Iteration 24 -- -Warning: htmlspecialchars_decode() expects parameter 2 to be long, resource given in %shtmlspecialchars_decode_variation2.php on line %d +Warning: htmlspecialchars_decode() expects parameter 2 to be long, resource given in %s on line %d NULL Done -