1
0
mirror of https://github.com/php/php-src.git synced 2026-04-27 10:16:41 +02:00

Strip MariaDB 10 prefix

Closes GH-7972
This commit is contained in:
Kamil Tekiela
2022-01-19 17:14:08 +00:00
parent 03816fba46
commit 5fc0db989e
4 changed files with 30 additions and 8 deletions
+3
View File
@@ -17,6 +17,9 @@ PHP NEWS
- MBString:
. Fixed bug GH-7902 (mb_send_mail may delimit headers with LF only). (cmb)
- MySQLnd:
. Fixed bug GH-7972 (MariaDB version prefix 5.5.5- is not stripped). (Kamil Tekiela)
- Sockets:
. Fixed ext/sockets build on Haiku. (David Carlier)
+20
View File
@@ -0,0 +1,20 @@
--TEST--
GH-7972 (MariaDB version prefix not always stripped)
--SKIPIF--
<?php
require_once 'skipif.inc';
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once "connect.inc";
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
// It seems we can only test the happy path...
if (str_starts_with($mysqli->server_info, '5.5.5-')) {
print("Expecting stripped prefix. Found: " . $mysqli->server_info . "\n");
}
?>
--EXPECT--
-8
View File
@@ -1436,14 +1436,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_server_version)(const MYSQLND_CONN_DATA *
return 0;
}
#define MARIA_DB_VERSION_HACK_PREFIX "5.5.5-"
if ((conn->server_capabilities & CLIENT_PLUGIN_AUTH)
&& !strncmp(p, MARIA_DB_VERSION_HACK_PREFIX, sizeof(MARIA_DB_VERSION_HACK_PREFIX)-1))
{
p += sizeof(MARIA_DB_VERSION_HACK_PREFIX)-1;
}
major = ZEND_STRTOL(p, &p, 10);
p += 1; /* consume the dot */
minor = ZEND_STRTOL(p, &p, 10);
+7
View File
@@ -41,6 +41,8 @@ const char mysqlnd_read_body_name[] = "mysqlnd_read_body";
#define ERROR_MARKER 0xFF
#define EODATA_MARKER 0xFE
#define MARIADB_RPL_VERSION_HACK "5.5.5-"
/* {{{ mysqlnd_command_to_text */
const char * const mysqlnd_command_to_text[COM_END] =
{
@@ -369,6 +371,11 @@ php_mysqlnd_greet_read(MYSQLND_CONN_DATA * conn, void * _packet)
DBG_RETURN(PASS);
}
/* MariaDB always sends 5.5.5 before version string: 5.5.5 was never released,
so just ignore it */
if (!strncmp((char *) p, MARIADB_RPL_VERSION_HACK, sizeof(MARIADB_RPL_VERSION_HACK) - 1))
p+= sizeof(MARIADB_RPL_VERSION_HACK) - 1;
packet->server_version = estrdup((char *)p);
p+= strlen(packet->server_version) + 1; /* eat the '\0' */
BAIL_IF_NO_MORE_DATA;