Skip to content

Commit e9c2dec

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix RSA memory leak in mysqlnd auth
2 parents e88c7bf + db08ef0 commit e9c2dec

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ext/mysqlnd/mysqlnd_auth.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_pub
726726
*/
727727
if (server_public_key_len <= passwd_len + 41) {
728728
/* password message is to long */
729+
RSA_free(server_public_key);
729730
SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
730731
DBG_ERR("password is too long");
731732
DBG_RETURN(NULL);
@@ -1016,13 +1017,15 @@ mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t serv
10161017
*/
10171018
if (server_public_key_len <= passwd_len + 41) {
10181019
/* password message is to long */
1020+
RSA_free(server_public_key);
10191021
SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
10201022
DBG_ERR("password is too long");
10211023
DBG_RETURN(0);
10221024
}
10231025

10241026
*crypted = emalloc(server_public_key_len);
10251027
RSA_public_encrypt(passwd_len + 1, (zend_uchar *) xor_str, *crypted, server_public_key, RSA_PKCS1_OAEP_PADDING);
1028+
RSA_free(server_public_key);
10261029
DBG_RETURN(server_public_key_len);
10271030
}
10281031
/* }}} */

0 commit comments

Comments
 (0)