From: Dmitry Stogov Date: Mon, 24 Dec 2007 18:09:50 +0000 (+0000) Subject: Additional fix for bug #42868 X-Git-Tag: RELEASE_1_3_1~472 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ed5a424b4f419ba293f0d4ea31cfb98b83ec92c8;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 c177c3ec8f..c2271f1734 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -186,36 +186,38 @@ ZEND_API void 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 + #define zendi_convert_to_long(op, holder, result) \ if (op == result) { \ convert_to_long(op); \ diff --git a/ext/standard/string.c b/ext/standard/string.c index fd6ed395e2..6e9727e1da 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2182,12 +2182,12 @@ PHP_FUNCTION(chunk_split) char *result; char *end = "\r\n"; int endlen = 2; - int chunklen = 76; + long chunklen = 76; int result_len; int argc = ZEND_NUM_ARGS(); - if (argc < 1 || argc > 3 || zend_get_parameters_ex(argc, &p_str, &p_chunklen, &p_ending) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|ZZ", &p_str, &p_chunklen, &p_ending) == FAILURE) { + return; } convert_to_string_ex(p_str); diff --git a/ext/standard/tests/strings/chunk_split_error.phpt b/ext/standard/tests/strings/chunk_split_error.phpt index 153250c1ae..9313b65b5b 100644 --- a/ext/standard/tests/strings/chunk_split_error.phpt +++ b/ext/standard/tests/strings/chunk_split_error.phpt @@ -32,9 +32,9 @@ echo "Done" --EXPECTF-- *** Testing chunk_split() : error conditions *** -- Testing chunk_split() function with Zero arguments -- -Warning: Wrong parameter count for chunk_split() in %s on line %d +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: Wrong parameter count for chunk_split() in %s on line %d +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 69308ea309..e01c126d3d 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 cc6eeef98c..6f8f2cde7f 100644 --- a/ext/standard/tests/strings/chunk_split_variation8.phpt +++ b/ext/standard/tests/strings/chunk_split_variation8.phpt @@ -32,9 +32,9 @@ $values = array ( -123, //negative integer 0234, //octal number 0x1A, //hexadecimal number - 2147483647, //max positive integer number - 2147483648, //max positive integer+1 - -2147483648, //min negative integer + PHP_INT_MAX, //max positive integer number + PHP_INT_MAX * 3, // Will overflow 32 bits on 32 bt system and 64 bits on 64 bit system + -PHP_INT_MAX -1, //min negative integer ); @@ -78,9 +78,10 @@ string(129) "This's heredoc string with and It has _speci@l ch@r$ 2222 !!!Now \k as escape char to test chunk_split():::" -- Iteration 7 -- - -Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d -bool(false) +string(129) "This's heredoc string with and + white space char. +It has _speci@l ch@r$ 2222 !!!Now \k as escape char to test +chunk_split():::" -- Iteration 8 -- Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d diff --git a/ext/standard/tests/strings/htmlspecialchars_decode_variation2.phpt b/ext/standard/tests/strings/htmlspecialchars_decode_variation2.phpt index 9ac0621896..ece2ac7b90 100644 --- a/ext/standard/tests/strings/htmlspecialchars_decode_variation2.phpt +++ b/ext/standard/tests/strings/htmlspecialchars_decode_variation2.phpt @@ -37,7 +37,7 @@ $values = array( // float data 10.5, -10.5, - 10.5e10, + 10.5e20, 10.6E-10, .5,