Skip to content

Fixed #74021 - fetch_array returned broken data #2357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
26 changes: 26 additions & 0 deletions ext/mysqli/tests/bug73800.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
Bug #73800 (sporadic segfault with MYSQLI_OPT_INT_AND_FLOAT_NATIVE)
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php

require_once("connect.inc");
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);

$link->query('SET @@global.max_allowed_packet = 67108864');
$link->close();

$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$link->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1);

$res = $link->query("SELECT RPAD('1',9000000,'1') as a,RPAD('1',9000000,'1') as b, 9223372036854775807 as c");
$r = $res->fetch_array();

var_dump($r['c']);
?>
--EXPECT--
int(9223372036854775807)
25 changes: 25 additions & 0 deletions ext/mysqli/tests/bug74021.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
Bug #74021 (fetch_array broken data. Data more then MEDIUMBLOB)
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php

require_once("connect.inc");
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);

$link->query('SET @@global.max_allowed_packet = 67108864');
$link->close();

$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$res = $link->query("SELECT RPAD('1',9000000,'1') as a,RPAD('1',9000000,'1') as b");
$r = $res->fetch_array();
var_dump(md5($r['a']));
var_dump(md5($r['b']));
?>
--EXPECT--
string(32) "42ca0fd16ab6b6d4b9d47dc0a4a8b12a"
string(32) "42ca0fd16ab6b6d4b9d47dc0a4a8b12a"
3 changes: 1 addition & 2 deletions ext/mysqlnd/mysqlnd_wireprotocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ php_mysqlnd_read_row_ex(MYSQLND_PFC * pfc,
We're allocating an extra byte, as php_mysqlnd_rowp_read_text_protocol_aux
needs to be able to append a terminating \0 for atoi/atof.
*/
*data_size = 1;
*data_size = 0;

while (1) {
if (FAIL == mysqlnd_read_header(pfc, vio, &header, stats, error_info)) {
Expand Down Expand Up @@ -1531,7 +1531,6 @@ php_mysqlnd_read_row_ex(MYSQLND_PFC * pfc,
pool->free_chunk(pool, *buffer);
*buffer = NULL;
}
(*data_size)--;
DBG_RETURN(ret);
}
/* }}} */
Expand Down