Skip to content

Commit 21de417

Browse files
committed
Fixed #74021 - fetch_array returned broken data
1 parent d5f0071 commit 21de417

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

ext/mysqli/tests/bug73800.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug #73800 (sporadic segfault with MYSQLI_OPT_INT_AND_FLOAT_NATIVE)
3+
--SKIPIF--
4+
<?php
5+
require_once('skipif.inc');
6+
require_once('skipifconnectfailure.inc');
7+
?>
8+
--FILE--
9+
<?php
10+
11+
require_once("connect.inc");
12+
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
13+
14+
$link->query('SET @@global.max_allowed_packet = 67108864');
15+
$link->close();
16+
17+
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
18+
$link->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1);
19+
20+
$res = $link->query("SELECT RPAD('1',9000000,'1') as a,RPAD('1',9000000,'1') as b, 9223372036854775807 as c");
21+
$r = $res->fetch_array();
22+
var_dump($r['c']);
23+
?>
24+
--EXPECT--
25+
int(9223372036854775807)

ext/mysqli/tests/bug74021.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug #74021 (fetch_array broken data. Data more then MEDIUMBLOB)
3+
--SKIPIF--
4+
<?php
5+
require_once('skipif.inc');
6+
require_once('skipifconnectfailure.inc');
7+
?>
8+
--FILE--
9+
<?php
10+
11+
require_once("connect.inc");
12+
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
13+
14+
$link->query('SET @@global.max_allowed_packet = 67108864');
15+
$link->close();
16+
17+
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
18+
$res = $link->query("SELECT RPAD('1',9000000,'1') as a,RPAD('1',9000000,'1') as b");
19+
$r = $res->fetch_array();
20+
var_dump(md5($r['a']));
21+
var_dump(md5($r['b']));
22+
?>
23+
--EXPECT--
24+
string(32) "42ca0fd16ab6b6d4b9d47dc0a4a8b12a"
25+
string(32) "42ca0fd16ab6b6d4b9d47dc0a4a8b12a"

ext/mysqlnd/mysqlnd_wireprotocol.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ php_mysqlnd_read_row_ex(MYSQLND_PFC * pfc,
14811481
We're allocating an extra byte, as php_mysqlnd_rowp_read_text_protocol_aux
14821482
needs to be able to append a terminating \0 for atoi/atof.
14831483
*/
1484-
*data_size = 1;
1484+
*data_size = 0;
14851485

14861486
while (1) {
14871487
if (FAIL == mysqlnd_read_header(pfc, vio, &header, stats, error_info)) {
@@ -1531,7 +1531,6 @@ php_mysqlnd_read_row_ex(MYSQLND_PFC * pfc,
15311531
pool->free_chunk(pool, *buffer);
15321532
*buffer = NULL;
15331533
}
1534-
(*data_size)--;
15351534
DBG_RETURN(ret);
15361535
}
15371536
/* }}} */

0 commit comments

Comments
 (0)