Skip to content

Commit 5fc0db9

Browse files
committed
Strip MariaDB 10 prefix
Closes GH-7972
1 parent 03816fb commit 5fc0db9

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ PHP NEWS
1717
- MBString:
1818
. Fixed bug GH-7902 (mb_send_mail may delimit headers with LF only). (cmb)
1919

20+
- MySQLnd:
21+
. Fixed bug GH-7972 (MariaDB version prefix 5.5.5- is not stripped). (Kamil Tekiela)
22+
2023
- Sockets:
2124
. Fixed ext/sockets build on Haiku. (David Carlier)
2225

ext/mysqli/tests/gh7932.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-7972 (MariaDB version prefix not always stripped)
3+
--SKIPIF--
4+
<?php
5+
require_once 'skipif.inc';
6+
require_once 'skipifconnectfailure.inc';
7+
?>
8+
--FILE--
9+
<?php
10+
require_once "connect.inc";
11+
12+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
13+
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
14+
15+
// It seems we can only test the happy path...
16+
if (str_starts_with($mysqli->server_info, '5.5.5-')) {
17+
print("Expecting stripped prefix. Found: " . $mysqli->server_info . "\n");
18+
}
19+
?>
20+
--EXPECT--

ext/mysqlnd/mysqlnd_connection.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,14 +1436,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_server_version)(const MYSQLND_CONN_DATA *
14361436
return 0;
14371437
}
14381438

1439-
#define MARIA_DB_VERSION_HACK_PREFIX "5.5.5-"
1440-
1441-
if ((conn->server_capabilities & CLIENT_PLUGIN_AUTH)
1442-
&& !strncmp(p, MARIA_DB_VERSION_HACK_PREFIX, sizeof(MARIA_DB_VERSION_HACK_PREFIX)-1))
1443-
{
1444-
p += sizeof(MARIA_DB_VERSION_HACK_PREFIX)-1;
1445-
}
1446-
14471439
major = ZEND_STRTOL(p, &p, 10);
14481440
p += 1; /* consume the dot */
14491441
minor = ZEND_STRTOL(p, &p, 10);

ext/mysqlnd/mysqlnd_wireprotocol.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ const char mysqlnd_read_body_name[] = "mysqlnd_read_body";
4141
#define ERROR_MARKER 0xFF
4242
#define EODATA_MARKER 0xFE
4343

44+
#define MARIADB_RPL_VERSION_HACK "5.5.5-"
45+
4446
/* {{{ mysqlnd_command_to_text */
4547
const char * const mysqlnd_command_to_text[COM_END] =
4648
{
@@ -369,6 +371,11 @@ php_mysqlnd_greet_read(MYSQLND_CONN_DATA * conn, void * _packet)
369371
DBG_RETURN(PASS);
370372
}
371373

374+
/* MariaDB always sends 5.5.5 before version string: 5.5.5 was never released,
375+
so just ignore it */
376+
if (!strncmp((char *) p, MARIADB_RPL_VERSION_HACK, sizeof(MARIADB_RPL_VERSION_HACK) - 1))
377+
p+= sizeof(MARIADB_RPL_VERSION_HACK) - 1;
378+
372379
packet->server_version = estrdup((char *)p);
373380
p+= strlen(packet->server_version) + 1; /* eat the '\0' */
374381
BAIL_IF_NO_MORE_DATA;

0 commit comments

Comments
 (0)