Skip to content

Commit dc6ede0

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed bug #79011 Fix memory leaks in mysqlnd debug functionality
2 parents c8eceba + bb5cdd9 commit dc6ede0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

ext/mysqlnd/mysqlnd_auth.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,12 @@ mysqlnd_caching_sha2_get_auth_data(struct st_mysqlnd_authentication_plugin * sel
913913
DBG_INF_FMT("salt(%d)=[%.*s]", auth_plugin_data_len, auth_plugin_data_len, auth_plugin_data);
914914
*auth_data_len = 0;
915915

916+
if (auth_plugin_data_len < SCRAMBLE_LENGTH) {
917+
SET_CLIENT_ERROR(conn->error_info, CR_MALFORMED_PACKET, UNKNOWN_SQLSTATE, "The server sent wrong length for scramble");
918+
DBG_ERR_FMT("The server sent wrong length for scramble %u. Expected %u", auth_plugin_data_len, SCRAMBLE_LENGTH);
919+
DBG_RETURN(NULL);
920+
}
921+
916922
DBG_INF("First auth step: send hashed password");
917923
/* copy scrambled pass*/
918924
if (passwd && passwd_len) {
@@ -1020,7 +1026,7 @@ mysqlnd_caching_sha2_get_and_use_key(MYSQLND_CONN_DATA *conn,
10201026
char xor_str[passwd_len + 1];
10211027
memcpy(xor_str, passwd, passwd_len);
10221028
xor_str[passwd_len] = '\0';
1023-
mysqlnd_xor_string(xor_str, passwd_len, (char *) auth_plugin_data, auth_plugin_data_len);
1029+
mysqlnd_xor_string(xor_str, passwd_len, (char *) auth_plugin_data, SCRAMBLE_LENGTH);
10241030

10251031
server_public_key_len = RSA_size(server_public_key);
10261032
/*

ext/mysqlnd/mysqlnd_debug.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,10 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_debug)
697697
MYSQLND_CLASS_METHODS_END;
698698

699699

700+
static void free_ptr(zval *zv) {
701+
efree(Z_PTR_P(zv));
702+
}
703+
700704
/* {{{ mysqlnd_debug_init */
701705
PHPAPI MYSQLND_DEBUG *
702706
mysqlnd_debug_init(const char * skip_functions[])
@@ -708,7 +712,7 @@ mysqlnd_debug_init(const char * skip_functions[])
708712
zend_stack_init(&ret->call_stack, sizeof(char *));
709713
zend_stack_init(&ret->call_time_stack, sizeof(uint64_t));
710714
zend_hash_init(&ret->not_filtered_functions, 0, NULL, NULL, 0);
711-
zend_hash_init(&ret->function_profiles, 0, NULL, NULL, 0);
715+
zend_hash_init(&ret->function_profiles, 0, NULL, free_ptr, 0);
712716

713717
ret->m = & mysqlnd_mysqlnd_debug_methods;
714718
ret->skip_functions = skip_functions;

0 commit comments

Comments
 (0)