Skip to content

Commit e4a348d

Browse files
committed
MFH: Fix #47050 mysqli_poll() modifies improper variables
1 parent b6f3208 commit e4a348d

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ PHP NEWS
2727
- Added ICU support to SQLite3 when using the bundled version. (Scott)
2828
- Enabled the salsa hashing functions. (Scott)
2929

30+
- Fixed bug #47050 (mysqli_poll() modifies improper variables). (Johannes)
3031
- Fixed bug #46957 (The tokenizer returns deprecated values). (Felipe)
3132
- Fixed bug #46944 (UTF-8 characters outside the BMP aren't encoded correctly).
3233
(Scott)

ext/mysqli/mysqli_fe.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ ZEND_END_ARG_INFO();
4242
ZEND_BEGIN_ARG_INFO(all_args_force_by_ref, 1)
4343
ZEND_END_ARG_INFO();
4444

45+
ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_poll, 0, 0, 4)
46+
ZEND_ARG_ARRAY_INFO(1, read, 1)
47+
ZEND_ARG_ARRAY_INFO(1, write, 1)
48+
ZEND_ARG_ARRAY_INFO(1, error, 1)
49+
ZEND_ARG_INFO(0, sec)
50+
ZEND_ARG_INFO(0, usec)
51+
ZEND_END_ARG_INFO();
4552

4653
/* {{{ mysqli_functions[]
4754
*
@@ -114,7 +121,7 @@ const zend_function_entry mysqli_functions[] = {
114121
PHP_FE(mysqli_options, NULL)
115122
PHP_FE(mysqli_ping, NULL)
116123
#if defined(MYSQLI_USE_MYSQLND)
117-
PHP_FE(mysqli_poll, NULL)
124+
PHP_FE(mysqli_poll, arginfo_mysqli_poll)
118125
#endif
119126
PHP_FE(mysqli_prepare, NULL)
120127
PHP_FE(mysqli_report, NULL)

ext/mysqli/tests/bug47050.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
Bug #47050 (mysqli_poll() modifies improper variables)
3+
--SKIPIF--
4+
<?php
5+
require_once('skipif.inc');
6+
require_once('skipifconnectfailure.inc');
7+
?>
8+
--FILE--
9+
<?php
10+
include ("connect.inc");
11+
12+
$link1 = mysqli_connect($host, $user, $passwd, null, $port, $socket);
13+
mysqli_select_db($link1, $db);
14+
15+
$link1->query("SELECT 'test'", MYSQLI_ASYNC);
16+
$all_links = array($link1);
17+
$links = $errors = $reject = $all_links;
18+
mysqli_poll($links, $errors, $reject, 1);
19+
20+
echo "links: ", sizeof($links), "\n";
21+
echo "errors: ", sizeof($errors), "\n";
22+
echo "reject: ", sizeof($reject), "\n";
23+
echo "all_links: ", sizeof($all_links), "\n";
24+
25+
$link1->close();
26+
?>
27+
--EXPECT--
28+
links: 1
29+
errors: 0
30+
reject: 0
31+
all_links: 1

0 commit comments

Comments
 (0)