From: Lauri Kenttä Date: Wed, 9 Jan 2019 08:50:26 +0000 (+0100) Subject: Fixed bug #77289 X-Git-Tag: php-7.3.2RC1~31 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63c38c9e4907b2d12885db7943b7053efe0d6c60;p=php Fixed bug #77289 Use mysqlnd_restart_psession and mysqlnd_end_psession in PDO MySQL. This makes sure we free last_message while ZMM is still live. --- diff --git a/NEWS b/NEWS index 48566bb357..7d9a45223a 100644 --- a/NEWS +++ b/NEWS @@ -54,6 +54,10 @@ PHP NEWS . Fixed bug #77273 (array_walk_recursive corrupts value types leading to PDO failure). (Nikita) +- PDO MySQL: + . Fixed bug #77289 (PDO MySQL segfaults with persistent connection). + (Lauri Kenttä) + - Phar: . Fixed bug #77247 (heap buffer overflow in phar_detect_phar_fname_ext). (Stas) diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index 2cec3daa42..eb3473f11e 100644 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -509,6 +509,21 @@ static int pdo_mysql_check_liveness(pdo_dbh_t *dbh) } /* }}} */ +/* {{{ pdo_mysql_request_shutdown */ +static void pdo_mysql_request_shutdown(pdo_dbh_t *dbh) +{ + pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data; + + PDO_DBG_ENTER("pdo_mysql_request_shutdown"); + PDO_DBG_INF_FMT("dbh=%p", dbh); +#ifdef PDO_USE_MYSQLND + if (H->server) { + mysqlnd_end_psession(H->server); + } +#endif +} +/* }}} */ + /* {{{ mysql_methods */ static const struct pdo_dbh_methods mysql_methods = { mysql_handle_closer, @@ -524,7 +539,7 @@ static const struct pdo_dbh_methods mysql_methods = { pdo_mysql_get_attribute, pdo_mysql_check_liveness, NULL, - NULL, + pdo_mysql_request_shutdown, NULL }; /* }}} */ @@ -589,6 +604,11 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options) pdo_mysql_error(dbh); goto cleanup; } +#if defined(PDO_USE_MYSQLND) + if (dbh->is_persistent) { + mysqlnd_restart_psession(H->server); + } +#endif dbh->driver_data = H; diff --git a/ext/pdo_mysql/tests/bug77289.phpt b/ext/pdo_mysql/tests/bug77289.phpt new file mode 100644 index 0000000000..db67524260 --- /dev/null +++ b/ext/pdo_mysql/tests/bug77289.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #77289: PDO MySQL segfaults with persistent connection +--SKIPIF-- + +--FILE-- + true]); +$pdo->exec("DROP TABLE IF EXISTS bug77289"); +$pdo->exec("CREATE TEMPORARY TABLE bug77289 (x INT)"); +$pdo->exec("UPDATE bug77289 SET x = x"); + +?> +===DONE=== +--EXPECT-- +===DONE===