andrey Fri, 26 Mar 2010 16:58:25 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=296885
Log: Fix tests that fail when the MySQL's socket file is not /tmp/mysql.sock as it is in when compiled from source and the default for mysqlnd. SuSE for example uses /var/run/mysql/mysql.sock . Also, sql.safe_mode (ext/mysql and ingres) needs the socket. Fix possible crashes in mysqlnd. When packets are shorter, functions should return error. Changed paths: U php/php-src/branches/PHP_5_3/ext/mysql/tests/connect.inc U php/php-src/branches/PHP_5_3/ext/mysqli/tests/connect.inc U php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_poll_kill.phpt U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c U php/php-src/trunk/ext/mysql/tests/connect.inc U php/php-src/trunk/ext/mysqli/tests/connect.inc U php/php-src/trunk/ext/mysqli/tests/mysqli_poll_kill.phpt U php/php-src/trunk/ext/mysqlnd/mysqlnd.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c U php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c
Modified: php/php-src/branches/PHP_5_3/ext/mysql/tests/connect.inc =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysql/tests/connect.inc 2010-03-26 16:55:03 UTC (rev 296884) +++ php/php-src/branches/PHP_5_3/ext/mysql/tests/connect.inc 2010-03-26 16:58:25 UTC (rev 296885) @@ -69,7 +69,9 @@ $socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null; $skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true; $connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0; - +if ($socket) { + ini_set('mysql.default_user', $socket); +} /* Development setting: test experimal features and/or feature requests that never worked before? */ $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ? ((1 == getenv("MYSQL_TEST_EXPERIMENTAL")) ? true : false) : Modified: php/php-src/branches/PHP_5_3/ext/mysqli/tests/connect.inc =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysqli/tests/connect.inc 2010-03-26 16:55:03 UTC (rev 296884) +++ php/php-src/branches/PHP_5_3/ext/mysqli/tests/connect.inc 2010-03-26 16:58:25 UTC (rev 296885) @@ -17,7 +17,9 @@ $socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null; $skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true; $connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0; - + if ($socket) { + ini_set('mysqli.default_socket', $socket); + } /* Development setting: test experimal features and/or feature requests that never worked before? */ $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ? ((1 == getenv("MYSQL_TEST_EXPERIMENTAL")) ? true : false) : Modified: php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_poll_kill.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_poll_kill.phpt 2010-03-26 16:55:03 UTC (rev 296884) +++ php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_poll_kill.phpt 2010-03-26 16:58:25 UTC (rev 296885) @@ -183,7 +183,7 @@ %unicode|string%(1) "1" } -Warning: mysqli_reap_async_query(): GREET %s +Warning: mysqli_reap_async_query(): RSET_HEADER % Warning: mysqli_reap_async_query(): MySQL server has gone away in %s on line %d [014] 2014/%s Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c 2010-03-26 16:55:03 UTC (rev 296884) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c 2010-03-26 16:58:25 UTC (rev 296885) @@ -516,20 +516,24 @@ if (!host || !host[0]) { host = "localhost"; } - if (!user || !user[0]) { - user = php_get_current_user(); + if (!user) { + DBG_INF_FMT("no user given, using empty string"); + user = ""; } if (!passwd) { + DBG_INF_FMT("no password given, using empty string"); passwd = ""; passwd_len = 0; } if (!db) { + DBG_INF_FMT("no db given, using empty string"); db = ""; db_len = 0; } host_len = strlen(host); #ifndef PHP_WIN32 if (host_len == sizeof("localhost") - 1 && !strncasecmp(host, "localhost", host_len)) { + DBG_INF_FMT("socket=%s", socket? socket:"n/a"); if (!socket) { socket = "/tmp/mysql.sock"; } Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-03-26 16:55:03 UTC (rev 296884) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-03-26 16:58:25 UTC (rev 296885) @@ -470,7 +470,7 @@ if (FAIL == (ret = result->m.read_result_metadata(result, conn TSRMLS_CC))) { /* For PS, we leave them in Prepared state */ - if (!stmt) { + if (!stmt && conn->current_result) { mnd_efree(conn->current_result); conn->current_result = NULL; } Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c 2010-03-26 16:55:03 UTC (rev 296884) +++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c 2010-03-26 16:58:25 UTC (rev 296885) @@ -353,6 +353,7 @@ DBG_ERR_FMT("GREET packet %d bytes shorter than expected", p - begin - packet->header.size); php_error_docref(NULL TSRMLS_CC, E_WARNING, "GREET packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", p - begin - packet->header.size); + DBG_RETURN(FAIL); } DBG_RETURN(PASS); @@ -554,6 +555,7 @@ DBG_ERR_FMT("OK packet %d bytes shorter than expected", p - begin - packet->header.size); php_error_docref(NULL TSRMLS_CC, E_WARNING, "OK packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", p - begin - packet->header.size); + DBG_RETURN(FAIL); } DBG_RETURN(PASS); @@ -628,6 +630,7 @@ DBG_ERR_FMT("EOF packet %d bytes shorter than expected", p - begin - packet->header.size); php_error_docref(NULL TSRMLS_CC, E_WARNING, "EOF packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", p - begin - packet->header.size); + DBG_RETURN(FAIL); } DBG_INF_FMT("EOF packet: fields=%d status=%d warnings=%d", @@ -788,8 +791,9 @@ } if (p - begin > packet->header.size) { DBG_ERR_FMT("RSET_HEADER packet %d bytes shorter than expected", p - begin - packet->header.size); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "GREET packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", + php_error_docref(NULL TSRMLS_CC, E_WARNING, "RSET_HEADER packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", p - begin - packet->header.size); + DBG_RETURN(FAIL); } DBG_RETURN(PASS); @@ -941,6 +945,7 @@ DBG_ERR_FMT("RSET field packet %d bytes shorter than expected", p - begin - packet->header.size); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Result set field packet "MYSQLND_SZ_T_SPEC" bytes " "shorter than expected", p - begin - packet->header.size); + DBG_RETURN(FAIL); } DBG_INF_FMT("allocing root. persistent=%d", packet->persistent_alloc); @@ -1634,6 +1639,7 @@ DBG_ERR_FMT("PREPARE packet %d bytes shorter than expected", p - begin - packet->header.size); php_error_docref(NULL TSRMLS_CC, E_WARNING, "PREPARE packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", p - begin - packet->header.size); + DBG_RETURN(FAIL); } DBG_RETURN(PASS); @@ -1694,6 +1700,7 @@ DBG_ERR_FMT("CHANGE_USER packet %d bytes shorter than expected", p - begin - packet->header.size); php_error_docref(NULL TSRMLS_CC, E_WARNING, "CHANGE_USER packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", p - begin - packet->header.size); + DBG_RETURN(FAIL); } DBG_RETURN(PASS); Modified: php/php-src/trunk/ext/mysql/tests/connect.inc =================================================================== --- php/php-src/trunk/ext/mysql/tests/connect.inc 2010-03-26 16:55:03 UTC (rev 296884) +++ php/php-src/trunk/ext/mysql/tests/connect.inc 2010-03-26 16:58:25 UTC (rev 296885) @@ -69,7 +69,9 @@ $socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null; $skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true; $connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0; - +if ($socket) { + ini_set('mysql.default_user', $socket); +} /* Development setting: test experimal features and/or feature requests that never worked before? */ $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ? ((1 == getenv("MYSQL_TEST_EXPERIMENTAL")) ? true : false) : Modified: php/php-src/trunk/ext/mysqli/tests/connect.inc =================================================================== --- php/php-src/trunk/ext/mysqli/tests/connect.inc 2010-03-26 16:55:03 UTC (rev 296884) +++ php/php-src/trunk/ext/mysqli/tests/connect.inc 2010-03-26 16:58:25 UTC (rev 296885) @@ -17,7 +17,9 @@ $socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null; $skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true; $connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0; - + if ($socket) { + ini_set('mysqli.default_socket', $socket); + } /* Development setting: test experimal features and/or feature requests that never worked before? */ $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ? ((1 == getenv("MYSQL_TEST_EXPERIMENTAL")) ? true : false) : Modified: php/php-src/trunk/ext/mysqli/tests/mysqli_poll_kill.phpt =================================================================== --- php/php-src/trunk/ext/mysqli/tests/mysqli_poll_kill.phpt 2010-03-26 16:55:03 UTC (rev 296884) +++ php/php-src/trunk/ext/mysqli/tests/mysqli_poll_kill.phpt 2010-03-26 16:58:25 UTC (rev 296885) @@ -183,7 +183,7 @@ %unicode|string%(1) "1" } -Warning: mysqli_reap_async_query(): GREET %s +Warning: mysqli_reap_async_query(): RSET_HEADER % Warning: mysqli_reap_async_query(): MySQL server has gone away in %s on line %d [014] 2014/%s Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd.c =================================================================== --- php/php-src/trunk/ext/mysqlnd/mysqlnd.c 2010-03-26 16:55:03 UTC (rev 296884) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd.c 2010-03-26 16:58:25 UTC (rev 296885) @@ -516,20 +516,24 @@ if (!host || !host[0]) { host = "localhost"; } - if (!user || !user[0]) { - user = php_get_current_user(); + if (!user) { + DBG_INF_FMT("no user given, using empty string"); + user = ""; } if (!passwd) { + DBG_INF_FMT("no password given, using empty string"); passwd = ""; passwd_len = 0; } if (!db) { + DBG_INF_FMT("no db given, using empty string"); db = ""; db_len = 0; } host_len = strlen(host); #ifndef PHP_WIN32 if (host_len == sizeof("localhost") - 1 && !strncasecmp(host, "localhost", host_len)) { + DBG_INF_FMT("socket=%s", socket? socket:"n/a"); if (!socket) { socket = "/tmp/mysql.sock"; } Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c =================================================================== --- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-03-26 16:55:03 UTC (rev 296884) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-03-26 16:58:25 UTC (rev 296885) @@ -470,7 +470,7 @@ if (FAIL == (ret = result->m.read_result_metadata(result, conn TSRMLS_CC))) { /* For PS, we leave them in Prepared state */ - if (!stmt) { + if (!stmt && conn->current_result) { mnd_efree(conn->current_result); conn->current_result = NULL; } Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c =================================================================== --- php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c 2010-03-26 16:55:03 UTC (rev 296884) +++ php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c 2010-03-26 16:58:25 UTC (rev 296885) @@ -353,6 +353,7 @@ DBG_ERR_FMT("GREET packet %d bytes shorter than expected", p - begin - packet->header.size); php_error_docref(NULL TSRMLS_CC, E_WARNING, "GREET packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", p - begin - packet->header.size); + DBG_RETURN(FAIL); } DBG_RETURN(PASS); @@ -554,6 +555,7 @@ DBG_ERR_FMT("OK packet %d bytes shorter than expected", p - begin - packet->header.size); php_error_docref(NULL TSRMLS_CC, E_WARNING, "OK packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", p - begin - packet->header.size); + DBG_RETURN(FAIL); } DBG_RETURN(PASS); @@ -628,6 +630,7 @@ DBG_ERR_FMT("EOF packet %d bytes shorter than expected", p - begin - packet->header.size); php_error_docref(NULL TSRMLS_CC, E_WARNING, "EOF packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", p - begin - packet->header.size); + DBG_RETURN(FAIL); } DBG_INF_FMT("EOF packet: fields=%d status=%d warnings=%d", @@ -788,8 +791,9 @@ } if (p - begin > packet->header.size) { DBG_ERR_FMT("RSET_HEADER packet %d bytes shorter than expected", p - begin - packet->header.size); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "GREET packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", + php_error_docref(NULL TSRMLS_CC, E_WARNING, "RSET_HEADER packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", p - begin - packet->header.size); + DBG_RETURN(FAIL); } DBG_RETURN(PASS); @@ -941,6 +945,7 @@ DBG_ERR_FMT("RSET field packet %d bytes shorter than expected", p - begin - packet->header.size); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Result set field packet "MYSQLND_SZ_T_SPEC" bytes " "shorter than expected", p - begin - packet->header.size); + DBG_RETURN(FAIL); } DBG_INF_FMT("allocing root. persistent=%d", packet->persistent_alloc); @@ -1634,6 +1639,7 @@ DBG_ERR_FMT("PREPARE packet %d bytes shorter than expected", p - begin - packet->header.size); php_error_docref(NULL TSRMLS_CC, E_WARNING, "PREPARE packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", p - begin - packet->header.size); + DBG_RETURN(FAIL); } DBG_RETURN(PASS); @@ -1694,6 +1700,7 @@ DBG_ERR_FMT("CHANGE_USER packet %d bytes shorter than expected", p - begin - packet->header.size); php_error_docref(NULL TSRMLS_CC, E_WARNING, "CHANGE_USER packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected", p - begin - packet->header.size); + DBG_RETURN(FAIL); } DBG_RETURN(PASS);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php