Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ext/bcmath/libbcmath/src/raise.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,12 @@ bc_raise_status bc_raise(bc_num base, long exponent, bc_num *result, size_t scal

if (bc_is_zero(base)) {
/* If the exponent is negative, it divides by 0 */
return is_neg ? BC_RAISE_STATUS_DIVIDE_BY_ZERO : BC_RAISE_STATUS_OK;
if (is_neg) {
return BC_RAISE_STATUS_DIVIDE_BY_ZERO;
}
bc_free_num (result);
*result = bc_copy_num(BCG(_zero_));
return BC_RAISE_STATUS_OK;
}

/* check overflow */
Expand Down
16 changes: 16 additions & 0 deletions ext/bcmath/tests/gh20006.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
GH-20006 (Power of 0 of BcMath number causes crash)
--EXTENSIONS--
bcmath
--FILE--
<?php
$n = new BcMath\Number("0");
var_dump(pow($n, 2));
?>
--EXPECTF--
object(BcMath\Number)#%d (2) {
["value"]=>
string(1) "0"
["scale"]=>
int(0)
}
11 changes: 5 additions & 6 deletions ext/filter/callback_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,21 @@
zend_result php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL)
{
zval retval;
int status;
zend_fcall_info_cache fcc;

if (!option_array || !zend_is_callable(option_array, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL)) {
if (!option_array || !zend_is_callable_ex(option_array, NULL, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL)) {
zend_type_error("%s(): Option must be a valid callback", get_active_function_name());
zval_ptr_dtor(value);
ZVAL_NULL(value);
return SUCCESS;
}

status = call_user_function(NULL, NULL, option_array, &retval, 1, value);
zend_call_known_fcc(&fcc, &retval, 1, value, NULL);
zval_ptr_dtor(value);

if (status == SUCCESS && !Z_ISUNDEF(retval)) {
zval_ptr_dtor(value);
if (!Z_ISUNDEF(retval)) {
ZVAL_COPY_VALUE(value, &retval);
} else {
zval_ptr_dtor(value);
ZVAL_NULL(value);
}
return SUCCESS;
Expand Down
40 changes: 40 additions & 0 deletions ext/mysqli/tests/bug67563.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--TEST--
Fix bug #67563 (mysqli compiled with mysqlnd does not take ipv6 adress as parameter)
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'connect.inc';

if ($host !== '127.0.0.1')
die('skip local test');

if (@stream_socket_client('udp://[::1]:8888') === false)
die('skip no IPv6 support 2');

if (!$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket));
}
?>
--INI--
max_execution_time=240
--FILE--
<?php
require_once 'connect.inc';

$hosts = ['::1', "[::1]:$port"];

foreach ($hosts as $host) {
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=%s dbname=%s, port=%s, socket=%s\n",
$host, $user, $passwd, $db, $port, $socket);
} else {
$link->close();
}
}

print "done!";
?>
--EXPECT--
done!
18 changes: 17 additions & 1 deletion ext/mysqlnd/mysqlnd_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,16 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect_handshake)(MYSQLND_CONN_DATA * conn,
}
/* }}} */

/* ipv6 addresses have at least two colons, which is how we can differentiate between domain names and addresses */
static bool mysqlnd_fast_is_ipv6_address(const char *s)
{
const char *first_colon = strchr(s, ':');
if (!first_colon) {
return false;
}
return strchr(first_colon + 1, ':') != NULL;
}

/* {{{ mysqlnd_conn_data::get_scheme */
static MYSQLND_STRING
MYSQLND_METHOD(mysqlnd_conn_data, get_scheme)(MYSQLND_CONN_DATA * conn, MYSQLND_CSTRING hostname, MYSQLND_CSTRING *socket_or_pipe, unsigned int port, bool * unix_socket, bool * named_pipe)
Expand Down Expand Up @@ -537,7 +547,13 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_scheme)(MYSQLND_CONN_DATA * conn, MYSQLND_
if (!port) {
port = 3306;
}
transport.l = mnd_sprintf(&transport.s, 0, "tcp://%s:%u", hostname.s, port);

/* ipv6 addresses are in the format [address]:port */
if (hostname.s[0] != '[' && mysqlnd_fast_is_ipv6_address(hostname.s)) {
transport.l = mnd_sprintf(&transport.s, 0, "tcp://[%s]:%u", hostname.s, port);
} else {
transport.l = mnd_sprintf(&transport.s, 0, "tcp://%s:%u", hostname.s, port);
}
}
DBG_INF_FMT("transport=%s", transport.s? transport.s:"OOM");
DBG_RETURN(transport);
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/tests/file/bug46347.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ $str = <<< EOF
part1.*.part2 = 1
EOF;

$file = __DIR__ . '/parse.ini';
$file = __DIR__ . '/bug46347.ini';
file_put_contents($file, $str);

var_dump(parse_ini_file($file));
?>
--CLEAN--
<?php
unlink(__DIR__.'/parse.ini');
unlink(__DIR__.'/bug46347.ini');
?>
--EXPECT--
array(1) {
Expand Down