diff options
author | Stanislav Malyshev <stas@php.net> | 2015-07-06 21:52:49 -0700 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2015-07-06 21:52:49 -0700 |
commit | 303d97feda15e97f9058e4ab96799ec2dbd3652f (patch) | |
tree | 8071010fb681343c4f6e8b559dd29064072015bc /ext/mysqlnd | |
parent | 8f2e08239fc1f8aabc26398393303fa685e810dd (diff) | |
parent | 0d2f147d80bd02d4d1ccaa0fa530d9d4846b3c75 (diff) | |
download | php-git-303d97feda15e97f9058e4ab96799ec2dbd3652f.tar.gz |
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
Fix bug #69669 (mysqlnd is vulnerable to BACKRONYM)
Fix bug #69923 - Buffer overflow and stack smashing error in phar_fix_filepath
Fix bug #69958 - Segfault in Phar::convertToData on invalid file
Conflicts:
ext/mysqlnd/mysqlnd.c
Diffstat (limited to 'ext/mysqlnd')
-rw-r--r-- | ext/mysqlnd/mysqlnd.c | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index 7e982f56c5..6e64a6ba68 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -400,7 +400,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_server_option)(MYSQLND_CONN_DATA * const c int2store(buffer, (unsigned int) option); ret = conn->m->simple_command(conn, COM_SET_OPTION, buffer, sizeof(buffer), PROT_EOF_PACKET, FALSE, TRUE TSRMLS_CC); - + conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); } DBG_RETURN(ret); @@ -464,27 +464,41 @@ mysqlnd_switch_to_ssl_if_needed( } #ifdef MYSQLND_SSL_SUPPORTED - if ((greet_packet->server_capabilities & CLIENT_SSL) && (mysql_flags & CLIENT_SSL)) { - zend_bool verify = mysql_flags & CLIENT_SSL_VERIFY_SERVER_CERT? TRUE:FALSE; - DBG_INF("Switching to SSL"); - if (!PACKET_WRITE(auth_packet, conn)) { - CONN_SET_STATE(conn, CONN_QUIT_SENT); - conn->m->send_close(conn TSRMLS_CC); - SET_CLIENT_ERROR(*conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone); - goto end; - } + if (mysql_flags & CLIENT_SSL) { + zend_bool server_has_ssl = (greet_packet->server_capabilities & CLIENT_SSL)? TRUE:FALSE; + if (server_has_ssl == FALSE) { + goto close_conn; + } else { + zend_bool verify = mysql_flags & CLIENT_SSL_VERIFY_SERVER_CERT? TRUE:FALSE; + DBG_INF("Switching to SSL"); + if (!PACKET_WRITE(auth_packet, conn)) { + goto close_conn; + } - conn->net->data->m.set_client_option(conn->net, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (const char *) &verify TSRMLS_CC); + conn->net->data->m.set_client_option(conn->net, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (const char *) &verify TSRMLS_CC); - if (FAIL == conn->net->data->m.enable_ssl(conn->net TSRMLS_CC)) { - goto end; + if (FAIL == conn->net->data->m.enable_ssl(conn->net TSRMLS_CC)) { + goto end; + } } } +#else + auth_packet->client_flags &= ~CLIENT_SSL; + if (!PACKET_WRITE(auth_packet, conn)) { + goto close_conn; + } #endif ret = PASS; end: PACKET_FREE(auth_packet); DBG_RETURN(ret); + +close_conn: + CONN_SET_STATE(conn, CONN_QUIT_SENT); + conn->m->send_close(conn TSRMLS_CC); + SET_CLIENT_ERROR(*conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone); + PACKET_FREE(auth_packet); + DBG_RETURN(ret); } /* }}} */ @@ -1563,7 +1577,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, sqlstate)(const MYSQLND_CONN_DATA * const conn /* {{{ mysqlnd_old_escape_string */ -PHPAPI ulong +PHPAPI ulong mysqlnd_old_escape_string(char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC) { DBG_ENTER("mysqlnd_old_escape_string"); @@ -1725,7 +1739,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, statistic)(MYSQLND_CONN_DATA * conn, char **me if (PASS == (ret = PACKET_READ(stats_header, conn))) { /* will be freed by Zend, thus don't use the mnd_ allocator */ - *message = estrndup(stats_header->message, stats_header->message_len); + *message = estrndup(stats_header->message, stats_header->message_len); *message_len = stats_header->message_len; DBG_INF(*message); } @@ -1851,7 +1865,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, shutdown)(MYSQLND_CONN_DATA * const conn, uint conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); } - DBG_RETURN(ret); + DBG_RETURN(ret); } /* }}} */ @@ -2350,7 +2364,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c ret = FAIL; break; } - + new_charset_name = mnd_pestrdup(value, conn->persistent); if (!new_charset_name) { goto oom; @@ -2429,11 +2443,11 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c default: ret = FAIL; } - conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); + conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); DBG_RETURN(ret); oom: SET_OOM_ERROR(*conn->error_info); - conn->m->local_tx_end(conn, this_func, FAIL TSRMLS_CC); + conn->m->local_tx_end(conn, this_func, FAIL TSRMLS_CC); end: DBG_RETURN(FAIL); } @@ -2551,7 +2565,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, use_result)(MYSQLND_CONN_DATA * const conn TSR conn->current_result = NULL; } while (0); - conn->m->local_tx_end(conn, this_func, result == NULL? FAIL:PASS TSRMLS_CC); + conn->m->local_tx_end(conn, this_func, result == NULL? FAIL:PASS TSRMLS_CC); } DBG_RETURN(result); @@ -2591,7 +2605,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, store_result)(MYSQLND_CONN_DATA * const conn T conn->current_result = NULL; } while (0); - conn->m->local_tx_end(conn, this_func, result == NULL? FAIL:PASS TSRMLS_CC); + conn->m->local_tx_end(conn, this_func, result == NULL? FAIL:PASS TSRMLS_CC); } DBG_RETURN(result); } @@ -2620,7 +2634,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_autocommit)(MYSQLND_CONN_DATA * conn, unsi if (PASS == conn->m->local_tx_start(conn, this_func TSRMLS_CC)) { ret = conn->m->query(conn, (mode) ? "SET AUTOCOMMIT=1":"SET AUTOCOMMIT=0", sizeof("SET AUTOCOMMIT=1") - 1 TSRMLS_CC); - conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); + conn->m->local_tx_end(conn, this_func, ret TSRMLS_CC); } DBG_RETURN(ret); |