Merge branch 'PHP-8.0' into PHP-8.1

* PHP-8.0:
  Fix bug where large bigints may be truncated
This commit is contained in:
Christoph M. Becker 2021-12-30 19:08:37 +01:00
commit ae9e98640a
No known key found for this signature in database
GPG Key ID: D66C9593118BCCB6
4 changed files with 98 additions and 2 deletions

3
NEWS
View File

@ -33,6 +33,9 @@ PHP NEWS
. Introduced MYSQLI_IS_MARIADB. (devnexen)
. Fixed bug GH-7746 (mysqli_sql_exception->getSqlState()). (Kamil Tekiela)
- MySQLnd:
. Fixed bug where large bigints may be truncated. (Nathan Freeman, cmb)
- OCI8:
. Fixed bug GH-7765 (php_oci_cleanup_global_handles segfaults at second
call). (cmb)

View File

@ -0,0 +1,44 @@
--TEST--
Bug GH-7837 (large bigints may be truncated)
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once("connect.inc");
if (strpos(mysqli_get_client_info(), "mysqlnd") === false) {
die("skip requires mysqlnd");
}
require_once("skipifconnectfailure.inc");
?>
--FILE--
<?php
require_once("connect.inc");
$mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, true);
$mysql->query("DROP TABLE IF EXISTS test");
$mysql->query("CREATE TABLE test (`ubigint` bigint unsigned NOT NULL) ENGINE=InnoDB");
$mysql->query("INSERT INTO test (`ubigint`) VALUES (18446744073709551615)");
$mysql->query("INSERT INTO test (`ubigint`) VALUES (9223372036854775808)");
$mysql->query("INSERT INTO test (`ubigint`) VALUES (1)");
$result = $mysql->query("SELECT ubigint FROM test");
var_dump($result->fetch_all());
?>
--EXPECT--
array(3) {
[0]=>
array(1) {
[0]=>
string(20) "18446744073709551615"
}
[1]=>
array(1) {
[0]=>
string(19) "9223372036854775808"
}
[2]=>
array(1) {
[0]=>
int(1)
}
}

View File

@ -1614,9 +1614,9 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_ROW_BUFFER * row_buffer, zval * fiel
} else {
uint64_t v =
#ifndef PHP_WIN32
(uint64_t) atoll((char *) p);
strtoull((char *) p, NULL, 10);
#else
(uint64_t) _atoi64((char *) p);
_strtoui64((char *) p, NULL, 10);
#endif
bool uns = fields_metadata[i].flags & UNSIGNED_FLAG? TRUE:FALSE;
/* We have to make it ASCIIZ temporarily */

View File

@ -0,0 +1,49 @@
--TEST--
Bug GH-7837 (large bigints may be truncated)
--EXTENSIONS--
pdo
pdo_mysql
mysqlnd
--SKIPIF--
<?php
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
MySQLPDOTest::skip();
if (!MySQLPDOTest::isPDOMySQLnd()) die('skip only for mysqlnd');
?>
--FILE--
<?php
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
$pdo = MySQLPDOTest::factory();
$tbl = "test";
$pdo->query("DROP TABLE IF EXISTS $tbl");
$pdo->query("CREATE TABLE $tbl (`ubigint` bigint unsigned NOT NULL) ENGINE=InnoDB");
$pdo->query("INSERT INTO $tbl (`ubigint`) VALUES (18446744073709551615)");
$pdo->query("INSERT INTO $tbl (`ubigint`) VALUES (9223372036854775808)");
$pdo->query("INSERT INTO $tbl (`ubigint`) VALUES (1)");
$result = $pdo->query("SELECT ubigint FROM $tbl")->fetchAll(PDO::FETCH_ASSOC);
var_dump($result);
?>
--CLEAN--
<?php
require dirname(__FILE__) . '/mysql_pdo_test.inc';
MySQLPDOTest::dropTestTable();
?>
--EXPECT--
array(3) {
[0]=>
array(1) {
["ubigint"]=>
string(20) "18446744073709551615"
}
[1]=>
array(1) {
["ubigint"]=>
string(19) "9223372036854775808"
}
[2]=>
array(1) {
["ubigint"]=>
int(1)
}
}