mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Additional fix for bug #42868
This commit is contained in:
parent
7c75fe7b8c
commit
ed5a424b4f
7 changed files with 52 additions and 45 deletions
|
@ -6,11 +6,13 @@ testing integer overflow (64bit)
|
|||
<?php
|
||||
|
||||
$doubles = array(
|
||||
9223372036854775808,
|
||||
9223372036854775809,
|
||||
9223372036854775818,
|
||||
9223372036854775908,
|
||||
9223372036854776808,
|
||||
PHP_INT_MAX,
|
||||
PHP_INT_MAX + 1,
|
||||
PHP_INT_MAX + 1000,
|
||||
PHP_INT_MAX * 2 + 4,
|
||||
-PHP_INT_MAX -1,
|
||||
-PHP_INT_MAX -2,
|
||||
-PHP_INT_MAX -1000,
|
||||
);
|
||||
|
||||
foreach ($doubles as $d) {
|
||||
|
@ -21,8 +23,10 @@ foreach ($doubles as $d) {
|
|||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
int(-9223372036854775808)
|
||||
int(-9223372036854775808)
|
||||
int(9223372036854775807)
|
||||
int(9223372036854775807)
|
||||
int(9223372036854775807)
|
||||
int(9223372036854775807)
|
||||
int(-9223372036854775808)
|
||||
int(-9223372036854775808)
|
||||
int(-9223372036854775808)
|
||||
|
|
|
@ -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); \
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -37,7 +37,7 @@ $values = array(
|
|||
// float data
|
||||
10.5,
|
||||
-10.5,
|
||||
10.5e10,
|
||||
10.5e20,
|
||||
10.6E-10,
|
||||
.5,
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue