1 diff -urpa php-7.2.8/ext/mysqlnd/mysqlnd_auth.c php-7.2.8.rev/ext/mysqlnd/mysqlnd_auth.c
2 --- php-7.2.8/ext/mysqlnd/mysqlnd_auth.c 2018-07-17 05:35:47.000000000 +0000
3 +++ php-7.2.8.rev/ext/mysqlnd/mysqlnd_auth.c 2018-07-22 00:12:44.558404079 +0000
4 @@ -89,7 +89,6 @@ mysqlnd_run_authentication(
10 zend_uchar * switch_to_auth_protocol_data = NULL;
11 size_t switch_to_auth_protocol_data_len = 0;
12 @@ -114,11 +113,10 @@ mysqlnd_run_authentication(
13 DBG_INF_FMT("salt(%d)=[%.*s]", plugin_data_len, plugin_data_len, plugin_data);
14 /* The data should be allocated with malloc() */
16 - scrambled_data = auth_plugin->methods.get_auth_data(
17 - NULL, &scrambled_data_len, conn, user, passwd,
18 - passwd_len, plugin_data, plugin_data_len,
19 - session_options, conn->protocol_frame_codec->data,
22 + auth_plugin->methods.get_auth_data(NULL, &scrambled_data_len, conn, user, passwd, passwd_len,
23 + plugin_data, plugin_data_len, session_options,
24 + conn->protocol_frame_codec->data, mysql_flags);
27 if (conn->error_info->error_no) {
28 @@ -129,7 +127,6 @@ mysqlnd_run_authentication(
32 - auth_plugin, plugin_data, plugin_data_len,
33 scrambled_data, scrambled_data_len,
34 &switch_to_auth_protocol, &switch_to_auth_protocol_len,
35 &switch_to_auth_protocol_data, &switch_to_auth_protocol_data_len
36 @@ -251,9 +248,6 @@ mysqlnd_auth_handshake(MYSQLND_CONN_DATA
37 unsigned int server_charset_no,
38 zend_bool use_full_blown_auth_packet,
39 const char * const auth_protocol,
40 - struct st_mysqlnd_authentication_plugin * auth_plugin,
41 - const zend_uchar * const orig_auth_plugin_data,
42 - const size_t orig_auth_plugin_data_len,
43 const zend_uchar * const auth_plugin_data,
44 const size_t auth_plugin_data_len,
45 char ** switch_to_auth_protocol,
46 @@ -324,11 +318,6 @@ mysqlnd_auth_handshake(MYSQLND_CONN_DATA
47 conn->charset = mysqlnd_find_charset_nr(auth_packet->charset_no);
50 - if (auth_plugin && auth_plugin->methods.handle_server_response) {
51 - auth_plugin->methods.handle_server_response(auth_plugin, conn,
52 - orig_auth_plugin_data, orig_auth_plugin_data_len, passwd, passwd_len);
55 if (FAIL == PACKET_READ(auth_resp_packet) || auth_resp_packet->response_code >= 0xFE) {
56 if (auth_resp_packet->response_code == 0xFE) {
57 /* old authentication with new server !*/
58 @@ -624,8 +613,7 @@ static struct st_mysqlnd_authentication_
62 - mysqlnd_native_auth_get_auth_data,
64 + mysqlnd_native_auth_get_auth_data
68 @@ -674,8 +662,7 @@ static struct st_mysqlnd_authentication_
72 - mysqlnd_pam_auth_get_auth_data,
74 + mysqlnd_pam_auth_get_auth_data
78 @@ -859,283 +846,17 @@ static struct st_mysqlnd_authentication_
82 - mysqlnd_sha256_auth_get_auth_data,
84 + mysqlnd_sha256_auth_get_auth_data
89 -/*************************************** CACHING SHA2 Password *******************************/
93 -#include "ext/hash/php_hash.h"
94 -#include "ext/hash/php_hash_sha.h"
96 -#define SHA256_LENGTH 32
98 -/* {{{ php_mysqlnd_scramble_sha2 */
99 -void php_mysqlnd_scramble_sha2(zend_uchar * const buffer, const zend_uchar * const scramble, const zend_uchar * const password, const size_t password_len)
101 - PHP_SHA256_CTX context;
102 - zend_uchar sha1[SHA256_LENGTH];
103 - zend_uchar sha2[SHA256_LENGTH];
105 - /* Phase 1: hash password */
106 - PHP_SHA256Init(&context);
107 - PHP_SHA256Update(&context, password, password_len);
108 - PHP_SHA256Final(sha1, &context);
110 - /* Phase 2: hash sha1 */
111 - PHP_SHA256Init(&context);
112 - PHP_SHA256Update(&context, (zend_uchar*)sha1, SHA256_LENGTH);
113 - PHP_SHA256Final(sha2, &context);
115 - /* Phase 3: hash scramble + sha2 */
116 - PHP_SHA256Init(&context);
117 - PHP_SHA256Update(&context, (zend_uchar*)sha2, SHA256_LENGTH);
118 - PHP_SHA256Update(&context, scramble, SCRAMBLE_LENGTH);
119 - PHP_SHA256Final(buffer, &context);
121 - /* let's crypt buffer now */
122 - php_mysqlnd_crypt(buffer, (const zend_uchar *)sha1, (const zend_uchar *)buffer, SHA256_LENGTH);
127 -/* {{{ mysqlnd_native_auth_get_auth_data */
129 -mysqlnd_caching_sha2_get_auth_data(struct st_mysqlnd_authentication_plugin * self,
130 - size_t * auth_data_len,
131 - MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
132 - const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
133 - const MYSQLND_SESSION_OPTIONS * const session_options,
134 - const MYSQLND_PFC_DATA * const pfc_data,
135 - zend_ulong mysql_flags
138 - zend_uchar * ret = NULL;
139 - DBG_ENTER("mysqlnd_caching_sha2_get_auth_data");
140 - DBG_INF_FMT("salt(%d)=[%.*s]", auth_plugin_data_len, auth_plugin_data_len, auth_plugin_data);
141 - *auth_data_len = 0;
143 - DBG_INF("First auth step: send hashed password");
144 - /* copy scrambled pass*/
145 - if (passwd && passwd_len) {
146 - ret = malloc(SHA256_LENGTH + 1);
147 - *auth_data_len = SHA256_LENGTH;
148 - php_mysqlnd_scramble_sha2((zend_uchar*)ret, auth_plugin_data, (zend_uchar*)passwd, passwd_len);
149 - ret[SHA256_LENGTH] = '\0';
150 - DBG_INF_FMT("hash(%d)=[%.*s]", *auth_data_len, *auth_data_len, ret);
157 -#ifdef MYSQLND_HAVE_SSL
159 -mysqlnd_caching_sha2_get_key(MYSQLND_CONN_DATA *conn)
162 - const MYSQLND_PFC_DATA * const pfc_data = conn->protocol_frame_codec->data;
163 - const char * fname = (pfc_data->sha256_server_public_key && pfc_data->sha256_server_public_key[0] != '\0')?
164 - pfc_data->sha256_server_public_key:
165 - MYSQLND_G(sha256_server_public_key);
166 - php_stream * stream;
167 - DBG_ENTER("mysqlnd_cached_sha2_get_key");
168 - DBG_INF_FMT("options_s256_pk=[%s] MYSQLND_G(sha256_server_public_key)=[%s]",
169 - pfc_data->sha256_server_public_key? pfc_data->sha256_server_public_key:"n/a",
170 - MYSQLND_G(sha256_server_public_key)? MYSQLND_G(sha256_server_public_key):"n/a");
171 - if (!fname || fname[0] == '\0') {
172 - MYSQLND_PACKET_CACHED_SHA2_RESULT *req_packet = NULL;
173 - MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE *pk_resp_packet = NULL;
176 - DBG_INF("requesting the public key from the server");
177 - req_packet = conn->payload_decoder_factory->m.get_cached_sha2_result_packet(conn->payload_decoder_factory, FALSE);
178 - pk_resp_packet = conn->payload_decoder_factory->m.get_sha256_pk_request_response_packet(conn->payload_decoder_factory, FALSE);
179 - req_packet->request = 1;
181 - if (! PACKET_WRITE(req_packet)) {
182 - DBG_ERR_FMT("Error while sending public key request packet");
183 - php_error(E_WARNING, "Error while sending public key request packet. PID=%d", getpid());
184 - SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT);
187 - if (FAIL == PACKET_READ(pk_resp_packet) || NULL == pk_resp_packet->public_key) {
188 - DBG_ERR_FMT("Error while receiving public key");
189 - php_error(E_WARNING, "Error while receiving public key. PID=%d", getpid());
190 - SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT);
193 - DBG_INF_FMT("Public key(%d):\n%s", pk_resp_packet->public_key_len, pk_resp_packet->public_key);
194 - /* now extract the public key */
196 - BIO * bio = BIO_new_mem_buf(pk_resp_packet->public_key, pk_resp_packet->public_key_len);
197 - ret = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL);
201 - PACKET_FREE(req_packet);
202 - PACKET_FREE(pk_resp_packet);
204 - DBG_INF_FMT("ret=%p", ret);
207 - SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE,
208 - "caching_sha2_server_public_key is not set for the connection or as mysqlnd.sha256_server_public_key");
209 - DBG_ERR("server_public_key is not set");
212 - zend_string * key_str;
213 - DBG_INF_FMT("Key in a file. [%s]", fname);
214 - stream = php_stream_open_wrapper((char *) fname, "rb", REPORT_ERRORS, NULL);
217 - if ((key_str = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0)) != NULL) {
218 - BIO * bio = BIO_new_mem_buf(ZSTR_VAL(key_str), ZSTR_LEN(key_str));
219 - ret = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL);
221 - DBG_INF("Successfully loaded");
222 - DBG_INF_FMT("Public key:%*.s", ZSTR_LEN(key_str), ZSTR_VAL(key_str));
223 - zend_string_release(key_str);
225 - php_stream_close(stream);
234 -/* {{{ mysqlnd_caching_sha2_get_key */
236 -mysqlnd_caching_sha2_get_and_use_key(MYSQLND_CONN_DATA *conn,
237 - const zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
238 - unsigned char **crypted,
239 - const char * const passwd,
240 - const size_t passwd_len)
242 -#ifdef MYSQLND_HAVE_SSL
243 - static RSA *server_public_key;
244 - server_public_key = mysqlnd_caching_sha2_get_key(conn);
246 - DBG_ENTER("mysqlnd_caching_sha2_get_and_use_key(");
248 - if (server_public_key) {
249 - int server_public_key_len;
250 - char xor_str[passwd_len + 1];
251 - memcpy(xor_str, passwd, passwd_len);
252 - xor_str[passwd_len] = '\0';
253 - mysqlnd_xor_string(xor_str, passwd_len, (char *) auth_plugin_data, auth_plugin_data_len);
255 - server_public_key_len = RSA_size(server_public_key);
257 - Because RSA_PKCS1_OAEP_PADDING is used there is a restriction on the passwd_len.
258 - RSA_PKCS1_OAEP_PADDING is recommended for new applications. See more here:
259 - http://www.openssl.org/docs/crypto/RSA_public_encrypt.html
261 - if ((size_t) server_public_key_len - 41 <= passwd_len) {
262 - /* password message is to long */
263 - SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
264 - DBG_ERR("password is too long");
268 - *crypted = emalloc(server_public_key_len);
269 - RSA_public_encrypt(passwd_len + 1, (zend_uchar *) xor_str, *crypted, server_public_key, RSA_PKCS1_OAEP_PADDING);
270 - DBG_RETURN(server_public_key_len);
274 - DBG_ENTER("mysqlnd_caching_sha2_get_and_use_key(");
275 - php_error_docref(NULL, E_WARNING, "PHP was built without openssl extension, can't send password encrypted");
281 -/* {{{ mysqlnd_native_auth_get_auth_data */
283 -mysqlnd_caching_sha2_handle_server_response(struct st_mysqlnd_authentication_plugin *self,
284 - MYSQLND_CONN_DATA * conn,
285 - const zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
286 - const char * const passwd,
287 - const size_t passwd_len)
289 - DBG_ENTER("mysqlnd_caching_sha2_handle_server_response");
290 - MYSQLND_PACKET_CACHED_SHA2_RESULT *result_packet;
291 - result_packet = conn->payload_decoder_factory->m.get_cached_sha2_result_packet(conn->payload_decoder_factory, FALSE);
293 - if (FAIL == PACKET_READ(result_packet)) {
297 - switch (result_packet->response_code) {
299 - DBG_INF("fast path suceeded");
300 - PACKET_FREE(result_packet);
303 - if (conn->vio->data->ssl || conn->unix_socket.s) {
304 - DBG_INF("fast path failed, doing full auth via SSL");
305 - result_packet->password = (zend_uchar *)passwd;
306 - result_packet->password_len = passwd_len + 1;
307 - PACKET_WRITE(result_packet);
309 - DBG_INF("fast path failed, doing full auth without SSL");
310 - result_packet->password_len = mysqlnd_caching_sha2_get_and_use_key(conn, auth_plugin_data, auth_plugin_data_len, &result_packet->password, passwd, passwd_len);
311 - PACKET_WRITE(result_packet);
312 - efree(result_packet->password);
314 - PACKET_FREE(result_packet);
317 - // The server tried to send a key, which we didn't expect
320 - php_error_docref(NULL, E_WARNING, "Unexpected server respose while doing caching_sha2 auth: %i", result_packet->response_code);
323 - PACKET_FREE(result_packet);
329 -static struct st_mysqlnd_authentication_plugin mysqlnd_caching_sha2_auth_plugin =
332 - MYSQLND_PLUGIN_API_VERSION,
333 - "auth_plugin_caching_sha2_password",
334 - MYSQLND_VERSION_ID,
335 - PHP_MYSQLND_VERSION,
336 - "PHP License 3.01",
337 - "Johannes Schlüter <johannes.schlueter@php.net>",
339 - NULL, /* no statistics , will be filled later if there are some */
340 - NULL, /* no statistics */
343 - NULL /* plugin shutdown */
347 - mysqlnd_caching_sha2_get_auth_data,
348 - mysqlnd_caching_sha2_handle_server_response
353 /* {{{ mysqlnd_register_builtin_authentication_plugins */
355 mysqlnd_register_builtin_authentication_plugins(void)
357 mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_native_auth_plugin);
358 mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_pam_authentication_plugin);
359 - mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_caching_sha2_auth_plugin);
360 #ifdef MYSQLND_HAVE_SSL
361 mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_sha256_authentication_plugin);
363 diff -urpa php-7.2.8/ext/mysqlnd/mysqlnd_auth.h php-7.2.8.rev/ext/mysqlnd/mysqlnd_auth.h
364 --- php-7.2.8/ext/mysqlnd/mysqlnd_auth.h 2018-07-17 05:35:47.000000000 +0000
365 +++ php-7.2.8.rev/ext/mysqlnd/mysqlnd_auth.h 2018-07-22 00:10:53.908410675 +0000
366 @@ -31,9 +31,26 @@ mysqlnd_auth_handshake(MYSQLND_CONN_DATA
367 unsigned int server_charset_no,
368 zend_bool use_full_blown_auth_packet,
369 const char * const auth_protocol,
370 - struct st_mysqlnd_authentication_plugin * auth_plugin,
371 - const zend_uchar * const orig_auth_plugin_data,
372 - const size_t orig_auth_plugin_data_len,
373 + const zend_uchar * const auth_plugin_data,
374 + const size_t auth_plugin_data_len,
375 + char ** switch_to_auth_protocol,
376 + size_t * switch_to_auth_protocol_len,
377 + zend_uchar ** switch_to_auth_protocol_data,
378 + size_t * switch_to_auth_protocol_data_len
382 +mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn,
383 + const char * const user,
384 + const char * const passwd,
385 + const size_t passwd_len,
386 + const char * const db,
387 + const size_t db_len,
388 + const MYSQLND_SESSION_OPTIONS * const session_options,
389 + zend_ulong mysql_flags,
390 + unsigned int server_charset_no,
391 + zend_bool use_full_blown_auth_packet,
392 + const char * const auth_protocol,
393 const zend_uchar * const auth_plugin_data,
394 const size_t auth_plugin_data_len,
395 char ** switch_to_auth_protocol,
396 diff -urpa php-7.2.8/ext/mysqlnd/mysqlnd_connection.c php-7.2.8.rev/ext/mysqlnd/mysqlnd_connection.c
397 --- php-7.2.8/ext/mysqlnd/mysqlnd_connection.c 2018-07-17 05:35:47.000000000 +0000
398 +++ php-7.2.8.rev/ext/mysqlnd/mysqlnd_connection.c 2018-07-22 00:10:53.909410674 +0000
399 @@ -678,10 +678,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, connec
402 const MYSQLND_CSTRING scheme = { transport.s, transport.l };
403 - /* This will be overwritten below with a copy, but we can use it during authentication */
404 - conn->unix_socket.s = (char *)socket_or_pipe.s;
405 if (FAIL == conn->m->connect_handshake(conn, &scheme, &username, &password, &database, mysql_flags)) {
406 - conn->unix_socket.s = NULL;
409 conn->unix_socket.s = NULL;
410 diff -urpa php-7.2.8/ext/mysqlnd/mysqlnd_enum_n_def.h php-7.2.8.rev/ext/mysqlnd/mysqlnd_enum_n_def.h
411 --- php-7.2.8/ext/mysqlnd/mysqlnd_enum_n_def.h 2018-07-17 05:35:47.000000000 +0000
412 +++ php-7.2.8.rev/ext/mysqlnd/mysqlnd_enum_n_def.h 2018-07-22 00:10:53.909410674 +0000
413 @@ -631,7 +631,6 @@ enum mysqlnd_packet_type
414 PROT_CHG_USER_RESP_PACKET,
415 PROT_SHA256_PK_REQUEST_PACKET,
416 PROT_SHA256_PK_REQUEST_RESPONSE_PACKET,
417 - PROT_CACHED_SHA2_RESULT_PACKET,
418 PROT_LAST /* should always be last */
421 diff -urpa php-7.2.8/ext/mysqlnd/mysqlnd_structs.h php-7.2.8.rev/ext/mysqlnd/mysqlnd_structs.h
422 --- php-7.2.8/ext/mysqlnd/mysqlnd_structs.h 2018-07-17 05:35:47.000000000 +0000
423 +++ php-7.2.8.rev/ext/mysqlnd/mysqlnd_structs.h 2018-07-22 00:10:53.909410674 +0000
424 @@ -970,7 +970,6 @@ struct st_mysqlnd_packet_chg_user_resp;
425 struct st_mysqlnd_packet_auth_pam;
426 struct st_mysqlnd_packet_sha256_pk_request;
427 struct st_mysqlnd_packet_sha256_pk_request_response;
428 -struct st_mysqlnd_packet_cached_sha2_result;
430 typedef struct st_mysqlnd_packet_greet * (*func_mysqlnd_protocol_payload_decoder_factory__get_greet_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, const zend_bool persistent);
431 typedef struct st_mysqlnd_packet_auth * (*func_mysqlnd_protocol_payload_decoder_factory__get_auth_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, const zend_bool persistent);
432 @@ -987,7 +986,6 @@ typedef struct st_mysqlnd_packet_prepare
433 typedef struct st_mysqlnd_packet_chg_user_resp*(*func_mysqlnd_protocol_payload_decoder_factory__get_change_user_response_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, const zend_bool persistent);
434 typedef struct st_mysqlnd_packet_sha256_pk_request *(*func_mysqlnd_protocol_payload_decoder_factory__get_sha256_pk_request_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, const zend_bool persistent);
435 typedef struct st_mysqlnd_packet_sha256_pk_request_response *(*func_mysqlnd_protocol_payload_decoder_factory__get_sha256_pk_request_response_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, const zend_bool persistent);
436 -typedef struct st_mysqlnd_packet_cached_sha2_result *(*func_mysqlnd_protocol_payload_decoder_factory__get_cached_sha2_result_packet)(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, const zend_bool persistent);
438 typedef enum_func_status (*func_mysqlnd_protocol_payload_decoder_factory__send_command)(
439 MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * payload_decoder_factory,
440 @@ -1045,7 +1043,6 @@ MYSQLND_CLASS_METHODS_TYPE(mysqlnd_proto
441 func_mysqlnd_protocol_payload_decoder_factory__get_change_user_response_packet get_change_user_response_packet;
442 func_mysqlnd_protocol_payload_decoder_factory__get_sha256_pk_request_packet get_sha256_pk_request_packet;
443 func_mysqlnd_protocol_payload_decoder_factory__get_sha256_pk_request_response_packet get_sha256_pk_request_response_packet;
444 - func_mysqlnd_protocol_payload_decoder_factory__get_cached_sha2_result_packet get_cached_sha2_result_packet;
446 func_mysqlnd_protocol_payload_decoder_factory__send_command send_command;
447 func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response;
448 @@ -1358,18 +1355,11 @@ typedef zend_uchar * (*func_auth_plugin_
449 const MYSQLND_PFC_DATA * const pfc_data, zend_ulong mysql_flags
452 -typedef void (*func_auth_plugin__handle_server_response)(struct st_mysqlnd_authentication_plugin * self,
453 - MYSQLND_CONN_DATA * conn,
454 - const zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
455 - const char * const passwd,
456 - const size_t passwd_len);
458 struct st_mysqlnd_authentication_plugin
460 struct st_mysqlnd_plugin_header plugin_header;
462 func_auth_plugin__get_auth_data get_auth_data;
463 - func_auth_plugin__handle_server_response handle_server_response;
467 diff -urpa php-7.2.8/ext/mysqlnd/mysqlnd_wireprotocol.c php-7.2.8.rev/ext/mysqlnd/mysqlnd_wireprotocol.c
468 --- php-7.2.8/ext/mysqlnd/mysqlnd_wireprotocol.c 2018-07-17 05:35:47.000000000 +0000
469 +++ php-7.2.8.rev/ext/mysqlnd/mysqlnd_wireprotocol.c 2018-07-22 00:11:47.108407504 +0000
470 @@ -2273,85 +2273,6 @@ php_mysqlnd_sha256_pk_request_response_f
475 -size_t php_mysqlnd_cached_sha2_result_write(void * _packet)
477 - MYSQLND_PACKET_CACHED_SHA2_RESULT * packet= (MYSQLND_PACKET_CACHED_SHA2_RESULT *) _packet;
478 - MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
479 - MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
480 - MYSQLND_VIO * vio = packet->header.vio;
481 - MYSQLND_STATS * stats = packet->header.stats;
483 - zend_uchar buffer[MYSQLND_HEADER_SIZE + packet->password_len + 1];
485 - ALLOCA_FLAG(use_heap)
486 - zend_uchar *buffer = do_alloca(MYSQLND_HEADER_SIZE + packet->password_len + 1, use_heap);
490 - DBG_ENTER("php_mysqlnd_cached_sha2_result_write");
492 - if (packet->request == 1) {
493 - int1store(buffer + MYSQLND_HEADER_SIZE, '\2');
494 - sent = pfc->data->m.send(pfc, vio, buffer, 1, stats, error_info);
496 - memcpy(buffer + MYSQLND_HEADER_SIZE, packet->password, packet->password_len);
497 - sent = pfc->data->m.send(pfc, vio, buffer, packet->password_len, stats, error_info);
501 - free_alloca(buffer, use_heap);
507 -static enum_func_status
508 -php_mysqlnd_cached_sha2_result_read(void * _packet)
510 - MYSQLND_PACKET_CACHED_SHA2_RESULT * packet= (MYSQLND_PACKET_CACHED_SHA2_RESULT *) _packet;
511 - MYSQLND_ERROR_INFO * error_info = packet->header.error_info;
512 - MYSQLND_PFC * pfc = packet->header.protocol_frame_codec;
513 - MYSQLND_VIO * vio = packet->header.vio;
514 - MYSQLND_STATS * stats = packet->header.stats;
515 - MYSQLND_CONNECTION_STATE * connection_state = packet->header.connection_state;
516 - zend_uchar buf[SHA256_PK_REQUEST_RESP_BUFFER_SIZE];
517 - zend_uchar *p = buf;
518 - const zend_uchar * const begin = buf;
520 - DBG_ENTER("php_mysqlnd_cached_sha2_result_read");
521 - if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, connection_state, buf, sizeof(buf), "PROT_CACHED_SHA2_RESULT_PACKET", PROT_CACHED_SHA2_RESULT_PACKET)) {
524 - BAIL_IF_NO_MORE_DATA;
527 - packet->response_code = uint1korr(p);
528 - BAIL_IF_NO_MORE_DATA;
531 - packet->result = uint1korr(p);
532 - BAIL_IF_NO_MORE_DATA;
537 - DBG_ERR_FMT("OK packet %d bytes shorter than expected", p - begin - packet->header.size);
538 - php_error_docref(NULL, E_WARNING, "SHA256_PK_REQUEST_RESPONSE packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
539 - p - begin - packet->header.size);
544 -php_mysqlnd_cached_sha2_result_free_mem(void * _packet, zend_bool stack_allocation)
546 - MYSQLND_PACKET_CACHED_SHA2_RESULT * p = (MYSQLND_PACKET_CACHED_SHA2_RESULT *) _packet;
548 - if (!stack_allocation) {
549 - mnd_pefree(p, p->header.persistent);
553 /* {{{ packet_methods */
555 mysqlnd_packet_methods packet_methods[PROT_LAST] =
556 @@ -2445,15 +2366,9 @@ mysqlnd_packet_methods packet_methods[PR
557 php_mysqlnd_sha256_pk_request_response_read,
559 php_mysqlnd_sha256_pk_request_response_free_mem,
560 - }, /* PROT_SHA256_PK_REQUEST_RESPONSE_PACKET */
562 - sizeof(MYSQLND_PACKET_CACHED_SHA2_RESULT),
563 - php_mysqlnd_cached_sha2_result_read,
564 - php_mysqlnd_cached_sha2_result_write,
565 - php_mysqlnd_cached_sha2_result_free_mem
566 - } /* PROT_CACHED_SHA2_RESULT_PACKET */
567 + } /* PROT_SHA256_PK_REQUEST_RESPONSE_PACKET */
573 /* {{{ mysqlnd_protocol::get_greet_packet */
574 @@ -2802,30 +2717,6 @@ MYSQLND_METHOD(mysqlnd_protocol, get_sha
578 -/* {{{ mysqlnd_protocol::init_cached_sha2_result_packet */
579 -static struct st_mysqlnd_packet_cached_sha2_result *
580 -MYSQLND_METHOD(mysqlnd_protocol, get_cached_sha2_result_packet)
581 -(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const factory, const zend_bool persistent)
583 - struct st_mysqlnd_packet_cached_sha2_result * packet = mnd_pecalloc(1, packet_methods[PROT_CACHED_SHA2_RESULT_PACKET].struct_size, persistent);
584 - DBG_ENTER("mysqlnd_protocol::init_cached_sha2_result_packet");
586 - memset(packet, 0, sizeof(*packet));
587 - packet->header.m = &packet_methods[PROT_CACHED_SHA2_RESULT_PACKET];
588 - packet->header.factory = factory;
590 - packet->header.protocol_frame_codec = factory->conn->protocol_frame_codec;
591 - packet->header.vio = factory->conn->vio;
592 - packet->header.stats = factory->conn->stats;
593 - packet->header.error_info = factory->conn->error_info;
594 - packet->header.connection_state = &factory->conn->state;
596 - packet->header.persistent = persistent;
598 - DBG_RETURN(packet);
603 /* {{{ mysqlnd_protocol::send_command */
604 static enum_func_status
605 @@ -3056,7 +2947,6 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_prot
606 MYSQLND_METHOD(mysqlnd_protocol, get_change_user_response_packet),
607 MYSQLND_METHOD(mysqlnd_protocol, get_sha256_pk_request_packet),
608 MYSQLND_METHOD(mysqlnd_protocol, get_sha256_pk_request_response_packet),
609 - MYSQLND_METHOD(mysqlnd_protocol, get_cached_sha2_result_packet),
611 MYSQLND_METHOD(mysqlnd_protocol, send_command),
612 MYSQLND_METHOD(mysqlnd_protocol, send_command_handle_response),
613 diff -urpa php-7.2.8/ext/mysqlnd/mysqlnd_wireprotocol.h php-7.2.8.rev/ext/mysqlnd/mysqlnd_wireprotocol.h
614 --- php-7.2.8/ext/mysqlnd/mysqlnd_wireprotocol.h 2018-07-17 05:35:47.000000000 +0000
615 +++ php-7.2.8.rev/ext/mysqlnd/mysqlnd_wireprotocol.h 2018-07-22 00:10:53.910410674 +0000
616 @@ -292,16 +292,6 @@ typedef struct st_mysqlnd_packet_sha256
617 size_t public_key_len;
618 } MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE;
620 -typedef struct st_mysqlnd_packet_cached_sha2_result {
621 - MYSQLND_PACKET_HEADER header;
622 - uint8_t response_code;
625 - zend_uchar * password;
626 - size_t password_len;
627 -} MYSQLND_PACKET_CACHED_SHA2_RESULT;
631 zend_ulong php_mysqlnd_net_field_length(const zend_uchar **packet);
632 zend_uchar * php_mysqlnd_net_store_length(zend_uchar *packet, const uint64_t length);