Lines Matching refs:packet

28 	if (UNEXPECTED((size_t)(p - begin) > packet->header.size)) { \
94 php_mysqlnd_net_field_length(const zend_uchar **packet) in php_mysqlnd_net_field_length() argument
96 const zend_uchar *p= (const zend_uchar *)*packet; in php_mysqlnd_net_field_length()
99 (*packet)++; in php_mysqlnd_net_field_length()
105 (*packet)++; in php_mysqlnd_net_field_length()
108 (*packet) += 3; in php_mysqlnd_net_field_length()
111 (*packet) += 4; in php_mysqlnd_net_field_length()
114 (*packet) += 9; in php_mysqlnd_net_field_length()
124 php_mysqlnd_net_field_length_ll(const zend_uchar **packet) in php_mysqlnd_net_field_length_ll() argument
126 const zend_uchar *p = (zend_uchar *)*packet; in php_mysqlnd_net_field_length_ll()
129 (*packet)++; in php_mysqlnd_net_field_length_ll()
135 (*packet)++; in php_mysqlnd_net_field_length_ll()
138 (*packet) += 3; in php_mysqlnd_net_field_length_ll()
141 (*packet) += 4; in php_mysqlnd_net_field_length_ll()
144 (*packet) += 9; in php_mysqlnd_net_field_length_ll()
153 php_mysqlnd_net_store_length(zend_uchar *packet, const uint64_t length) in php_mysqlnd_net_store_length() argument
156 *packet = (zend_uchar) length; in php_mysqlnd_net_store_length()
157 return packet + 1; in php_mysqlnd_net_store_length()
161 *packet++ = 252; in php_mysqlnd_net_store_length()
162 int2store(packet,(unsigned int) length); in php_mysqlnd_net_store_length()
163 return packet + 2; in php_mysqlnd_net_store_length()
167 *packet++ = 253; in php_mysqlnd_net_store_length()
168 int3store(packet,(zend_ulong) length); in php_mysqlnd_net_store_length()
169 return packet + 3; in php_mysqlnd_net_store_length()
171 *packet++ = 254; in php_mysqlnd_net_store_length()
172 int8store(packet, length); in php_mysqlnd_net_store_length()
173 return packet + 8; in php_mysqlnd_net_store_length()
342 MYSQLND_PACKET_GREET *packet= (MYSQLND_PACKET_GREET *) _packet; in php_mysqlnd_greet_read() local
355 …if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, co… in php_mysqlnd_greet_read()
360 packet->authentication_plugin_data.s = packet->intern_auth_plugin_data; in php_mysqlnd_greet_read()
361 packet->authentication_plugin_data.l = sizeof(packet->intern_auth_plugin_data); in php_mysqlnd_greet_read()
363 packet->protocol_version = uint1korr(p); in php_mysqlnd_greet_read()
367 if (ERROR_MARKER == packet->protocol_version) { in php_mysqlnd_greet_read()
368 php_mysqlnd_read_error_from_line(p, packet->header.size - 1, in php_mysqlnd_greet_read()
369 packet->error, sizeof(packet->error), in php_mysqlnd_greet_read()
370 &packet->error_no, packet->sqlstate in php_mysqlnd_greet_read()
377 if (packet->error_no == 1040) { in php_mysqlnd_greet_read()
378 memcpy(packet->sqlstate, "08004", MYSQLND_SQLSTATE_LENGTH); in php_mysqlnd_greet_read()
389 packet->server_version = estrdup((char *)p); in php_mysqlnd_greet_read()
390 p+= strlen(packet->server_version) + 1; /* eat the '\0' */ in php_mysqlnd_greet_read()
393 packet->thread_id = uint4korr(p); in php_mysqlnd_greet_read()
397 memcpy(packet->authentication_plugin_data.s, p, SCRAMBLE_LENGTH_323); in php_mysqlnd_greet_read()
405 packet->server_capabilities = uint2korr(p); in php_mysqlnd_greet_read()
408 DBG_INF_FMT("4.1 server_caps=%u\n", (uint32_t) packet->server_capabilities); in php_mysqlnd_greet_read()
410 packet->charset_no = uint1korr(p); in php_mysqlnd_greet_read()
414 packet->server_status = uint2korr(p); in php_mysqlnd_greet_read()
423 if ((size_t) (p - buf) < packet->header.size) { in php_mysqlnd_greet_read()
425 …memcpy(packet->authentication_plugin_data.s + SCRAMBLE_LENGTH_323, p, SCRAMBLE_LENGTH - SCRAMBLE_L… in php_mysqlnd_greet_read()
429 packet->pre41 = TRUE; in php_mysqlnd_greet_read()
433 if ((size_t) (p - buf) < packet->header.size) { in php_mysqlnd_greet_read()
439 packet->server_capabilities |= ((uint32_t) uint2korr(pad_start)) << 16; in php_mysqlnd_greet_read()
441 packet->authentication_plugin_data.l = uint1korr(pad_start + 2); in php_mysqlnd_greet_read()
442 if (packet->authentication_plugin_data.l > SCRAMBLE_LENGTH) { in php_mysqlnd_greet_read()
444 char * new_auth_plugin_data = emalloc(packet->authentication_plugin_data.l); in php_mysqlnd_greet_read()
447 memcpy(new_auth_plugin_data, packet->authentication_plugin_data.s, SCRAMBLE_LENGTH); in php_mysqlnd_greet_read()
449 …memcpy(new_auth_plugin_data + SCRAMBLE_LENGTH, p, packet->authentication_plugin_data.l - SCRAMBLE_… in php_mysqlnd_greet_read()
450 p+= (packet->authentication_plugin_data.l - SCRAMBLE_LENGTH); in php_mysqlnd_greet_read()
451 packet->authentication_plugin_data.s = new_auth_plugin_data; in php_mysqlnd_greet_read()
455 if (packet->server_capabilities & CLIENT_PLUGIN_AUTH) { in php_mysqlnd_greet_read()
458 packet->auth_protocol = estrdup((char *)p); in php_mysqlnd_greet_read()
459 p+= strlen(packet->auth_protocol) + 1; /* eat the '\0' */ in php_mysqlnd_greet_read()
463 packet->protocol_version, packet->server_version, packet->thread_id); in php_mysqlnd_greet_read()
466 packet->server_capabilities, packet->charset_no, packet->server_status, in php_mysqlnd_greet_read()
467 packet->auth_protocol? packet->auth_protocol:"n/a", packet->authentication_plugin_data.l); in php_mysqlnd_greet_read()
471 DBG_ERR_FMT("GREET packet %zu bytes shorter than expected", p - begin - packet->header.size); in php_mysqlnd_greet_read()
473 p - begin - packet->header.size); in php_mysqlnd_greet_read()
509 MYSQLND_PACKET_AUTH * packet= (MYSQLND_PACKET_AUTH *) _packet; in php_mysqlnd_auth_write() local
518 if (!packet->is_change_user_packet) { in php_mysqlnd_auth_write()
519 int4store(p, packet->client_flags); in php_mysqlnd_auth_write()
522 int4store(p, packet->max_packet_size); in php_mysqlnd_auth_write()
525 int1store(p, packet->charset_no); in php_mysqlnd_auth_write()
532 if (packet->send_auth_data || packet->is_change_user_packet) { in php_mysqlnd_auth_write()
533 len = MIN(strlen(packet->user), MYSQLND_MAX_ALLOWED_USER_LEN); in php_mysqlnd_auth_write()
534 p = zend_mempcpy(p, packet->user, len); in php_mysqlnd_auth_write()
538 if (packet->auth_data == NULL) { in php_mysqlnd_auth_write()
539 packet->auth_data_len = 0; in php_mysqlnd_auth_write()
541 if (packet->auth_data_len > 0xFF) { in php_mysqlnd_auth_write()
549 int1store(p, (int8_t)packet->auth_data_len); in php_mysqlnd_auth_write()
552 if (sizeof(buffer) < (packet->auth_data_len + (p - buffer))) { in php_mysqlnd_auth_write()
556 if (packet->auth_data_len) { in php_mysqlnd_auth_write()
557 p = zend_mempcpy(p, packet->auth_data, packet->auth_data_len); in php_mysqlnd_auth_write()
560 if (packet->db_len > 0) { in php_mysqlnd_auth_write()
562 size_t real_db_len = MIN(MYSQLND_MAX_ALLOWED_DB_LEN, packet->db_len); in php_mysqlnd_auth_write()
563 p = zend_mempcpy(p, packet->db, real_db_len); in php_mysqlnd_auth_write()
565 } else if (packet->is_change_user_packet) { in php_mysqlnd_auth_write()
570 if (packet->is_change_user_packet) { in php_mysqlnd_auth_write()
571 if (packet->charset_no) { in php_mysqlnd_auth_write()
572 int2store(p, packet->charset_no); in php_mysqlnd_auth_write()
577 if (packet->auth_plugin_name) { in php_mysqlnd_auth_write()
578 len = MIN(strlen(packet->auth_plugin_name), sizeof(buffer) - (p - buffer) - 1); in php_mysqlnd_auth_write()
579 p = zend_mempcpy(p, packet->auth_plugin_name, len); in php_mysqlnd_auth_write()
583 if (packet->connect_attr && zend_hash_num_elements(packet->connect_attr)) { in php_mysqlnd_auth_write()
589 ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(packet->connect_attr, key, entry_value) { in php_mysqlnd_auth_write()
607 ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(packet->connect_attr, key, entry_value) { in php_mysqlnd_auth_write()
625 if (packet->is_change_user_packet) { in php_mysqlnd_auth_write()
628 const unsigned int silent = packet->silent; in php_mysqlnd_auth_write()
651 MYSQLND_PACKET_AUTH_RESPONSE * packet= (MYSQLND_PACKET_AUTH_RESPONSE *) _packet; in php_mysqlnd_auth_response_read() local
664 …if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, co… in php_mysqlnd_auth_response_read()
670 packet->response_code = uint1korr(p); in php_mysqlnd_auth_response_read()
674 if (ERROR_MARKER == packet->response_code) { in php_mysqlnd_auth_response_read()
675 php_mysqlnd_read_error_from_line(p, packet->header.size - 1, in php_mysqlnd_auth_response_read()
676 packet->error, sizeof(packet->error), in php_mysqlnd_auth_response_read()
677 &packet->error_no, packet->sqlstate in php_mysqlnd_auth_response_read()
681 if (0xFE == packet->response_code) { in php_mysqlnd_auth_response_read()
683 if (packet->header.size > (size_t) (p - buf)) { in php_mysqlnd_auth_response_read()
684 packet->new_auth_protocol = mnd_pestrdup((char *)p, FALSE); in php_mysqlnd_auth_response_read()
685 packet->new_auth_protocol_len = strlen(packet->new_auth_protocol); in php_mysqlnd_auth_response_read()
686 p+= packet->new_auth_protocol_len + 1; /* +1 for the \0 */ in php_mysqlnd_auth_response_read()
688 packet->new_auth_protocol_data_len = packet->header.size - (size_t) (p - buf); in php_mysqlnd_auth_response_read()
689 if (packet->new_auth_protocol_data_len) { in php_mysqlnd_auth_response_read()
690 packet->new_auth_protocol_data = mnd_emalloc(packet->new_auth_protocol_data_len); in php_mysqlnd_auth_response_read()
691 memcpy(packet->new_auth_protocol_data, p, packet->new_auth_protocol_data_len); in php_mysqlnd_auth_response_read()
693 DBG_INF_FMT("The server requested switching auth plugin to : %s", packet->new_auth_protocol); in php_mysqlnd_auth_response_read()
694 …_FMT("Server salt : [%zu][%.*s]", packet->new_auth_protocol_data_len, (int) packet->new_auth_proto… in php_mysqlnd_auth_response_read()
699 packet->affected_rows = php_mysqlnd_net_field_length_ll(&p); in php_mysqlnd_auth_response_read()
702 packet->last_insert_id = php_mysqlnd_net_field_length_ll(&p); in php_mysqlnd_auth_response_read()
705 packet->server_status = uint2korr(p); in php_mysqlnd_auth_response_read()
709 packet->warning_count = uint2korr(p); in php_mysqlnd_auth_response_read()
714 if (packet->header.size > (size_t) (p - buf) && (net_len = php_mysqlnd_net_field_length(&p))) { in php_mysqlnd_auth_response_read()
715 packet->message_len = MIN(net_len, buf_len - (p - begin)); in php_mysqlnd_auth_response_read()
716 packet->message = mnd_pestrndup((char *)p, packet->message_len, FALSE); in php_mysqlnd_auth_response_read()
718 packet->message = NULL; in php_mysqlnd_auth_response_read()
719 packet->message_len = 0; in php_mysqlnd_auth_response_read()
723 packet->affected_rows, packet->last_insert_id, packet->server_status, in php_mysqlnd_auth_response_read()
724 packet->warning_count); in php_mysqlnd_auth_response_read()
729 DBG_ERR_FMT("OK packet %zu bytes shorter than expected", p - begin - packet->header.size); in php_mysqlnd_auth_response_read()
731 p - begin - packet->header.size); in php_mysqlnd_auth_response_read()
765 MYSQLND_PACKET_CHANGE_AUTH_RESPONSE *packet= (MYSQLND_PACKET_CHANGE_AUTH_RESPONSE *) _packet; in php_mysqlnd_change_auth_response_write() local
771 size_t total_packet_size = packet->auth_data_len + MYSQLND_HEADER_SIZE; in php_mysqlnd_change_auth_response_write()
777 if (packet->auth_data_len) { in php_mysqlnd_change_auth_response_write()
778 p = zend_mempcpy(p, packet->auth_data, packet->auth_data_len); in php_mysqlnd_change_auth_response_write()
803 MYSQLND_PACKET_OK *packet= (MYSQLND_PACKET_OK *) _packet; in php_mysqlnd_ok_read() local
817 …if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, co… in php_mysqlnd_ok_read()
823 packet->field_count = uint1korr(p); in php_mysqlnd_ok_read()
827 if (ERROR_MARKER == packet->field_count) { in php_mysqlnd_ok_read()
828 php_mysqlnd_read_error_from_line(p, packet->header.size - 1, in php_mysqlnd_ok_read()
829 packet->error, sizeof(packet->error), in php_mysqlnd_ok_read()
830 &packet->error_no, packet->sqlstate in php_mysqlnd_ok_read()
835 packet->affected_rows = php_mysqlnd_net_field_length_ll(&p); in php_mysqlnd_ok_read()
838 packet->last_insert_id = php_mysqlnd_net_field_length_ll(&p); in php_mysqlnd_ok_read()
841 packet->server_status = uint2korr(p); in php_mysqlnd_ok_read()
845 packet->warning_count = uint2korr(p); in php_mysqlnd_ok_read()
850 if (packet->header.size > (size_t) (p - buf) && (net_len = php_mysqlnd_net_field_length(&p))) { in php_mysqlnd_ok_read()
851 packet->message_len = MIN(net_len, buf_len - (p - begin)); in php_mysqlnd_ok_read()
852 packet->message = mnd_pestrndup((char *)p, packet->message_len, FALSE); in php_mysqlnd_ok_read()
854 packet->message = NULL; in php_mysqlnd_ok_read()
855 packet->message_len = 0; in php_mysqlnd_ok_read()
859 packet->affected_rows, packet->last_insert_id, packet->server_status, in php_mysqlnd_ok_read()
860 packet->warning_count); in php_mysqlnd_ok_read()
866 DBG_ERR_FMT("OK packet %zu bytes shorter than expected", p - begin - packet->header.size); in php_mysqlnd_ok_read()
868 p - begin - packet->header.size); in php_mysqlnd_ok_read()
897 MYSQLND_PACKET_EOF *packet= (MYSQLND_PACKET_EOF *) _packet; in php_mysqlnd_eof_read() local
910 …if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, co… in php_mysqlnd_eof_read()
916 packet->field_count = uint1korr(p); in php_mysqlnd_eof_read()
920 if (ERROR_MARKER == packet->field_count) { in php_mysqlnd_eof_read()
921 php_mysqlnd_read_error_from_line(p, packet->header.size - 1, in php_mysqlnd_eof_read()
922 packet->error, sizeof(packet->error), in php_mysqlnd_eof_read()
923 &packet->error_no, packet->sqlstate in php_mysqlnd_eof_read()
933 if (packet->header.size > 1) { in php_mysqlnd_eof_read()
934 packet->warning_count = uint2korr(p); in php_mysqlnd_eof_read()
938 packet->server_status = uint2korr(p); in php_mysqlnd_eof_read()
942 packet->warning_count = 0; in php_mysqlnd_eof_read()
943 packet->server_status = 0; in php_mysqlnd_eof_read()
949 packet->field_count, packet->server_status, packet->warning_count); in php_mysqlnd_eof_read()
953 DBG_ERR_FMT("EOF packet %zu bytes shorter than expected", p - begin - packet->header.size); in php_mysqlnd_eof_read()
955 p - begin - packet->header.size); in php_mysqlnd_eof_read()
965 MYSQLND_PACKET_COMMAND * packet= (MYSQLND_PACKET_COMMAND *) _packet; in php_mysqlnd_cmd_write() local
983 vio->data->m.consume_uneaten_data(vio, packet->command); in php_mysqlnd_cmd_write()
986 if (!packet->argument.s || !packet->argument.l) { in php_mysqlnd_cmd_write()
989 int1store(buffer + MYSQLND_HEADER_SIZE, packet->command); in php_mysqlnd_cmd_write()
992 size_t tmp_len = packet->argument.l + 1 + MYSQLND_HEADER_SIZE; in php_mysqlnd_cmd_write()
1000 int1store(p, packet->command); in php_mysqlnd_cmd_write()
1003 memcpy(p, packet->argument.s, packet->argument.l); in php_mysqlnd_cmd_write()
1024 MYSQLND_PACKET_RSET_HEADER * packet= (MYSQLND_PACKET_RSET_HEADER *) _packet; in php_mysqlnd_rset_header_read() local
1039 …if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, co… in php_mysqlnd_rset_header_read()
1052 php_mysqlnd_read_error_from_line(p, packet->header.size - 1, in php_mysqlnd_rset_header_read()
1053 packet->error_info.error, sizeof(packet->error_info.error), in php_mysqlnd_rset_header_read()
1054 &packet->error_info.error_no, packet->error_info.sqlstate in php_mysqlnd_rset_header_read()
1059 packet->field_count = php_mysqlnd_net_field_length(&p); in php_mysqlnd_rset_header_read()
1062 switch (packet->field_count) { in php_mysqlnd_rset_header_read()
1072 len = packet->header.size - 1; in php_mysqlnd_rset_header_read()
1073 packet->info_or_local_file.s = mnd_emalloc(len + 1); in php_mysqlnd_rset_header_read()
1074 memcpy(packet->info_or_local_file.s, p, len); in php_mysqlnd_rset_header_read()
1075 packet->info_or_local_file.s[len] = '\0'; in php_mysqlnd_rset_header_read()
1076 packet->info_or_local_file.l = len; in php_mysqlnd_rset_header_read()
1080 packet->affected_rows = php_mysqlnd_net_field_length_ll(&p); in php_mysqlnd_rset_header_read()
1083 packet->last_insert_id = php_mysqlnd_net_field_length_ll(&p); in php_mysqlnd_rset_header_read()
1086 packet->server_status = uint2korr(p); in php_mysqlnd_rset_header_read()
1090 packet->warning_count = uint2korr(p); in php_mysqlnd_rset_header_read()
1094 if (packet->header.size > (size_t) (p - buf) && (len = php_mysqlnd_net_field_length(&p))) { in php_mysqlnd_rset_header_read()
1095 packet->info_or_local_file.s = mnd_emalloc(len + 1); in php_mysqlnd_rset_header_read()
1096 memcpy(packet->info_or_local_file.s, p, len); in php_mysqlnd_rset_header_read()
1097 packet->info_or_local_file.s[len] = '\0'; in php_mysqlnd_rset_header_read()
1098 packet->info_or_local_file.l = len; in php_mysqlnd_rset_header_read()
1101 packet->affected_rows, packet->last_insert_id, in php_mysqlnd_rset_header_read()
1102 packet->server_status, packet->warning_count); in php_mysqlnd_rset_header_read()
1113 DBG_ERR_FMT("RSET_HEADER packet %zu bytes shorter than expected", p - begin - packet->header.size); in php_mysqlnd_rset_header_read()
1115 p - begin - packet->header.size); in php_mysqlnd_rset_header_read()
1153 MYSQLND_PACKET_RES_FIELD *packet = (MYSQLND_PACKET_RES_FIELD *) _packet; in php_mysqlnd_rset_field_read() local
1170 …if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, co… in php_mysqlnd_rset_field_read()
1174 if (packet->skip_parsing) { in php_mysqlnd_rset_field_read()
1183 php_mysqlnd_read_error_from_line(p, packet->header.size - 1, in php_mysqlnd_rset_field_read()
1184 packet->error_info.error, sizeof(packet->error_info.error), in php_mysqlnd_rset_field_read()
1185 &packet->error_info.error_no, packet->error_info.sqlstate in php_mysqlnd_rset_field_read()
1187 DBG_ERR_FMT("Server error : (%u) %s", packet->error_info.error_no, packet->error_info.error); in php_mysqlnd_rset_field_read()
1189 } else if (EODATA_MARKER == *p && packet->header.size < 8) { in php_mysqlnd_rset_field_read()
1196 meta = packet->metadata; in php_mysqlnd_rset_field_read()
1211 if ((size_t)((p - begin) + 12) > packet->header.size) { in php_mysqlnd_rset_field_read()
1251 if (packet->header.size > (size_t) (p - buf) && in php_mysqlnd_rset_field_read()
1257 meta->def = packet->memory_pool->get_chunk(packet->memory_pool, len + 1); in php_mysqlnd_rset_field_read()
1264 root_ptr = meta->root = packet->memory_pool->get_chunk(packet->memory_pool, total_len); in php_mysqlnd_rset_field_read()
1323 DBG_ERR_FMT("RSET field packet %zu bytes shorter than expected", p - begin - packet->header.size); in php_mysqlnd_rset_field_read()
1325 "shorter than expected", p - begin - packet->header.size); in php_mysqlnd_rset_field_read()
1660 MYSQLND_PACKET_ROW *packet = (MYSQLND_PACKET_ROW *) _packet; in php_mysqlnd_rowp_read() local
1661 MYSQLND_ERROR_INFO * error_info = &packet->error_info; in php_mysqlnd_rowp_read()
1672 packet->result_set_memory_pool, &packet->row_buffer, &data_size); in php_mysqlnd_rowp_read()
1677 MYSQLND_HEADER_SIZE + packet->header.size, in php_mysqlnd_rowp_read()
1690 packet->header.size = data_size; in php_mysqlnd_rowp_read()
1691 packet->row_buffer.size = data_size; in php_mysqlnd_rowp_read()
1693 if (ERROR_MARKER == (*(p = packet->row_buffer.ptr))) { in php_mysqlnd_rowp_read()
1701 packet->error_info.error, in php_mysqlnd_rowp_read()
1702 sizeof(packet->error_info.error), in php_mysqlnd_rowp_read()
1703 &packet->error_info.error_no, in php_mysqlnd_rowp_read()
1704 packet->error_info.sqlstate in php_mysqlnd_rowp_read()
1707 packet->eof = TRUE; in php_mysqlnd_rowp_read()
1710 packet->warning_count = uint2korr(p); in php_mysqlnd_rowp_read()
1712 packet->server_status = uint2korr(p); in php_mysqlnd_rowp_read()
1714 DBG_INF_FMT("server_status=%u warning_count=%u", packet->server_status, packet->warning_count); in php_mysqlnd_rowp_read()
1717 packet->eof = FALSE; in php_mysqlnd_rowp_read()
1719 packet->binary_protocol? STAT_ROWS_FETCHED_FROM_SERVER_PS: in php_mysqlnd_rowp_read()
1733 MYSQLND_PACKET_STATS *packet= (MYSQLND_PACKET_STATS *) _packet; in php_mysqlnd_stats_read() local
1744 …if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, co… in php_mysqlnd_stats_read()
1748 packet->message.s = mnd_emalloc(packet->header.size + 1); in php_mysqlnd_stats_read()
1749 memcpy(packet->message.s, buf, packet->header.size); in php_mysqlnd_stats_read()
1750 packet->message.s[packet->header.size] = '\0'; in php_mysqlnd_stats_read()
1751 packet->message.l = packet->header.size; in php_mysqlnd_stats_read()
1776 MYSQLND_PACKET_PREPARE_RESPONSE *packet= (MYSQLND_PACKET_PREPARE_RESPONSE *) _packet; in php_mysqlnd_prepare_read() local
1791 …if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, co… in php_mysqlnd_prepare_read()
1796 data_size = packet->header.size; in php_mysqlnd_prepare_read()
1797 packet->error_code = uint1korr(p); in php_mysqlnd_prepare_read()
1801 if (ERROR_MARKER == packet->error_code) { in php_mysqlnd_prepare_read()
1803 packet->error_info.error, in php_mysqlnd_prepare_read()
1804 sizeof(packet->error_info.error), in php_mysqlnd_prepare_read()
1805 &packet->error_info.error_no, in php_mysqlnd_prepare_read()
1806 packet->error_info.sqlstate in php_mysqlnd_prepare_read()
1819 packet->stmt_id = uint4korr(p); in php_mysqlnd_prepare_read()
1824 packet->field_count = uint2korr(p); in php_mysqlnd_prepare_read()
1828 packet->param_count = uint2korr(p); in php_mysqlnd_prepare_read()
1837 packet->warning_count = uint2korr(p); in php_mysqlnd_prepare_read()
1841 packet->stmt_id, packet->field_count, packet->param_count); in php_mysqlnd_prepare_read()
1847 DBG_ERR_FMT("PREPARE packet %zu bytes shorter than expected", p - begin - packet->header.size); in php_mysqlnd_prepare_read()
1849 p - begin - packet->header.size); in php_mysqlnd_prepare_read()
1859 MYSQLND_PACKET_CHG_USER_RESPONSE *packet= (MYSQLND_PACKET_CHG_USER_RESPONSE *) _packet; in php_mysqlnd_chg_user_read() local
1873 …if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, co… in php_mysqlnd_chg_user_read()
1884 packet->response_code = uint1korr(p); in php_mysqlnd_chg_user_read()
1887 …if (packet->header.size == 1 && buf[0] == EODATA_MARKER && (packet->server_capabilities & CLIENT_S… in php_mysqlnd_chg_user_read()
1889 packet->server_asked_323_auth = TRUE; in php_mysqlnd_chg_user_read()
1893 if (ERROR_MARKER == packet->response_code) { in php_mysqlnd_chg_user_read()
1894 php_mysqlnd_read_error_from_line(p, packet->header.size - 1, in php_mysqlnd_chg_user_read()
1895 packet->error_info.error, in php_mysqlnd_chg_user_read()
1896 sizeof(packet->error_info.error), in php_mysqlnd_chg_user_read()
1897 &packet->error_info.error_no, in php_mysqlnd_chg_user_read()
1898 packet->error_info.sqlstate in php_mysqlnd_chg_user_read()
1902 if (packet->response_code == 0xFE && packet->header.size > (size_t) (p - buf)) { in php_mysqlnd_chg_user_read()
1903 packet->new_auth_protocol = mnd_pestrdup((char *)p, FALSE); in php_mysqlnd_chg_user_read()
1904 packet->new_auth_protocol_len = strlen(packet->new_auth_protocol); in php_mysqlnd_chg_user_read()
1905 p+= packet->new_auth_protocol_len + 1; /* +1 for the \0 */ in php_mysqlnd_chg_user_read()
1906 packet->new_auth_protocol_data_len = packet->header.size - (size_t) (p - buf); in php_mysqlnd_chg_user_read()
1907 if (packet->new_auth_protocol_data_len) { in php_mysqlnd_chg_user_read()
1908 packet->new_auth_protocol_data = mnd_emalloc(packet->new_auth_protocol_data_len); in php_mysqlnd_chg_user_read()
1909 memcpy(packet->new_auth_protocol_data, p, packet->new_auth_protocol_data_len); in php_mysqlnd_chg_user_read()
1911 DBG_INF_FMT("The server requested switching auth plugin to : %s", packet->new_auth_protocol); in php_mysqlnd_chg_user_read()
1912 …DBG_INF_FMT("Server salt : [%*s]", (int) packet->new_auth_protocol_data_len, packet->new_auth_prot… in php_mysqlnd_chg_user_read()
1917 DBG_ERR_FMT("CHANGE_USER packet %zu bytes shorter than expected", p - begin - packet->header.size); in php_mysqlnd_chg_user_read()
1919 p - begin - packet->header.size); in php_mysqlnd_chg_user_read()
1971 …MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE * packet= (MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE *) … in php_mysqlnd_sha256_pk_request_response_read() local
1985 …if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, co… in php_mysqlnd_sha256_pk_request_response_read()
1993 packet->public_key_len = packet->header.size - (p - buf); in php_mysqlnd_sha256_pk_request_response_read()
1994 packet->public_key = mnd_emalloc(packet->public_key_len + 1); in php_mysqlnd_sha256_pk_request_response_read()
1995 memcpy(packet->public_key, p, packet->public_key_len); in php_mysqlnd_sha256_pk_request_response_read()
1996 packet->public_key[packet->public_key_len] = '\0'; in php_mysqlnd_sha256_pk_request_response_read()
2001 DBG_ERR_FMT("OK packet %zu bytes shorter than expected", p - begin - packet->header.size); in php_mysqlnd_sha256_pk_request_response_read()
2003 p - begin - packet->header.size); in php_mysqlnd_sha256_pk_request_response_read()
2025 MYSQLND_PACKET_CACHED_SHA2_RESULT * packet= (MYSQLND_PACKET_CACHED_SHA2_RESULT *) _packet; in php_mysqlnd_cached_sha2_result_write() local
2031 zend_uchar *buffer = do_alloca(MYSQLND_HEADER_SIZE + packet->password_len + 1, use_heap); in php_mysqlnd_cached_sha2_result_write()
2036 if (packet->request == 1) { in php_mysqlnd_cached_sha2_result_write()
2040 if (packet->password_len != 0) { in php_mysqlnd_cached_sha2_result_write()
2041 memcpy(buffer + MYSQLND_HEADER_SIZE, packet->password, packet->password_len); in php_mysqlnd_cached_sha2_result_write()
2043 sent = pfc->data->m.send(pfc, vio, buffer, packet->password_len, stats, error_info); in php_mysqlnd_cached_sha2_result_write()
2053 MYSQLND_PACKET_CACHED_SHA2_RESULT * packet= (MYSQLND_PACKET_CACHED_SHA2_RESULT *) _packet; in php_mysqlnd_cached_sha2_result_read() local
2065 …if (FAIL == mysqlnd_read_packet_header_and_body(&(packet->header), pfc, vio, stats, error_info, co… in php_mysqlnd_cached_sha2_result_read()
2070 packet->response_code = uint1korr(p); in php_mysqlnd_cached_sha2_result_read()
2074 if (ERROR_MARKER == packet->response_code) { in php_mysqlnd_cached_sha2_result_read()
2075 php_mysqlnd_read_error_from_line(p, packet->header.size - 1, in php_mysqlnd_cached_sha2_result_read()
2076 packet->error, sizeof(packet->error), in php_mysqlnd_cached_sha2_result_read()
2077 &packet->error_no, packet->sqlstate in php_mysqlnd_cached_sha2_result_read()
2081 if (0xFE == packet->response_code) { in php_mysqlnd_cached_sha2_result_read()
2083 if (packet->header.size > (size_t) (p - buf)) { in php_mysqlnd_cached_sha2_result_read()
2084 packet->new_auth_protocol = mnd_pestrdup((char *)p, FALSE); in php_mysqlnd_cached_sha2_result_read()
2085 packet->new_auth_protocol_len = strlen(packet->new_auth_protocol); in php_mysqlnd_cached_sha2_result_read()
2086 p+= packet->new_auth_protocol_len + 1; /* +1 for the \0 */ in php_mysqlnd_cached_sha2_result_read()
2088 packet->new_auth_protocol_data_len = packet->header.size - (size_t) (p - buf); in php_mysqlnd_cached_sha2_result_read()
2089 if (packet->new_auth_protocol_data_len) { in php_mysqlnd_cached_sha2_result_read()
2090 packet->new_auth_protocol_data = mnd_emalloc(packet->new_auth_protocol_data_len); in php_mysqlnd_cached_sha2_result_read()
2091 memcpy(packet->new_auth_protocol_data, p, packet->new_auth_protocol_data_len); in php_mysqlnd_cached_sha2_result_read()
2093 DBG_INF_FMT("The server requested switching auth plugin to : %s", packet->new_auth_protocol); in php_mysqlnd_cached_sha2_result_read()
2094 …_FMT("Server salt : [%zu][%.*s]", packet->new_auth_protocol_data_len, (int) packet->new_auth_proto… in php_mysqlnd_cached_sha2_result_read()
2099 if (0x1 != packet->response_code) { in php_mysqlnd_cached_sha2_result_read()
2100 DBG_ERR_FMT("Unexpected response code %d", packet->response_code); in php_mysqlnd_cached_sha2_result_read()
2104 packet->response_code = uint1korr(p); in php_mysqlnd_cached_sha2_result_read()
2108 packet->result = uint1korr(p); in php_mysqlnd_cached_sha2_result_read()
2114 DBG_ERR_FMT("OK packet %zu bytes shorter than expected", p - begin - packet->header.size); in php_mysqlnd_cached_sha2_result_read()
2116 p - begin - packet->header.size); in php_mysqlnd_cached_sha2_result_read()
2210 MYSQLND_METHOD(mysqlnd_protocol, init_greet_packet)(struct st_mysqlnd_packet_greet *packet) in MYSQLND_METHOD()
2213 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2214 packet->header.m = &packet_methods[PROT_GREET_PACKET]; in MYSQLND_METHOD()
2222 MYSQLND_METHOD(mysqlnd_protocol, init_auth_packet)(struct st_mysqlnd_packet_auth *packet) in MYSQLND_METHOD()
2225 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2226 packet->header.m = &packet_methods[PROT_AUTH_PACKET]; in MYSQLND_METHOD()
2234 …METHOD(mysqlnd_protocol, init_auth_response_packet)(struct st_mysqlnd_packet_auth_response *packet) in MYSQLND_METHOD()
2237 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2238 packet->header.m = &packet_methods[PROT_AUTH_RESP_PACKET]; in MYSQLND_METHOD()
2246 …_protocol, init_change_auth_response_packet)(struct st_mysqlnd_packet_change_auth_response *packet) in MYSQLND_METHOD()
2249 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2250 packet->header.m = &packet_methods[PROT_CHANGE_AUTH_RESP_PACKET]; in MYSQLND_METHOD()
2258 MYSQLND_METHOD(mysqlnd_protocol, init_ok_packet)(struct st_mysqlnd_packet_ok *packet) in MYSQLND_METHOD()
2261 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2262 packet->header.m = &packet_methods[PROT_OK_PACKET]; in MYSQLND_METHOD()
2270 MYSQLND_METHOD(mysqlnd_protocol, init_eof_packet)(struct st_mysqlnd_packet_eof *packet) in MYSQLND_METHOD()
2273 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2274 packet->header.m = &packet_methods[PROT_EOF_PACKET]; in MYSQLND_METHOD()
2282 MYSQLND_METHOD(mysqlnd_protocol, init_command_packet)(struct st_mysqlnd_packet_command *packet) in MYSQLND_METHOD()
2285 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2286 packet->header.m = &packet_methods[PROT_CMD_PACKET]; in MYSQLND_METHOD()
2294 …LND_METHOD(mysqlnd_protocol, init_rset_header_packet)(struct st_mysqlnd_packet_rset_header *packet) in MYSQLND_METHOD()
2297 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2298 packet->header.m = &packet_methods[PROT_RSET_HEADER_PACKET]; in MYSQLND_METHOD()
2306 …QLND_METHOD(mysqlnd_protocol, init_result_field_packet)(struct st_mysqlnd_packet_res_field *packet) in MYSQLND_METHOD()
2309 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2310 packet->header.m = &packet_methods[PROT_RSET_FLD_PACKET]; in MYSQLND_METHOD()
2318 MYSQLND_METHOD(mysqlnd_protocol, init_row_packet)(struct st_mysqlnd_packet_row *packet) in MYSQLND_METHOD()
2321 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2322 packet->header.m = &packet_methods[PROT_ROW_PACKET]; in MYSQLND_METHOD()
2330 MYSQLND_METHOD(mysqlnd_protocol, init_stats_packet)(struct st_mysqlnd_packet_stats *packet) in MYSQLND_METHOD()
2333 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2334 packet->header.m = &packet_methods[PROT_STATS_PACKET]; in MYSQLND_METHOD()
2342 …(mysqlnd_protocol, init_prepare_response_packet)(struct st_mysqlnd_packet_prepare_response *packet) in MYSQLND_METHOD()
2345 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2346 packet->header.m = &packet_methods[PROT_PREPARE_RESP_PACKET]; in MYSQLND_METHOD()
2354 …mysqlnd_protocol, init_change_user_response_packet)(struct st_mysqlnd_packet_chg_user_resp *packet) in MYSQLND_METHOD()
2357 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2358 packet->header.m = &packet_methods[PROT_CHG_USER_RESP_PACKET]; in MYSQLND_METHOD()
2366 …ysqlnd_protocol, init_sha256_pk_request_packet)(struct st_mysqlnd_packet_sha256_pk_request *packet) in MYSQLND_METHOD()
2369 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2370 packet->header.m = &packet_methods[PROT_SHA256_PK_REQUEST_PACKET]; in MYSQLND_METHOD()
2378 …nit_sha256_pk_request_response_packet)(struct st_mysqlnd_packet_sha256_pk_request_response *packet) in MYSQLND_METHOD()
2381 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2382 packet->header.m = &packet_methods[PROT_SHA256_PK_REQUEST_RESPONSE_PACKET]; in MYSQLND_METHOD()
2389 …qlnd_protocol, init_cached_sha2_result_packet)(struct st_mysqlnd_packet_cached_sha2_result *packet) in MYSQLND_METHOD()
2392 memset(packet, 0, sizeof(*packet)); in MYSQLND_METHOD()
2393 packet->header.m = &packet_methods[PROT_CACHED_SHA2_RESULT_PACKET]; in MYSQLND_METHOD()