summaryrefslogtreecommitdiff
path: root/ext/mysqlnd/mysqlnd_auth.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-03-23 12:01:15 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-03-23 12:01:15 +0100
commite9c2dec7205503d786ff3a6b2b30afd9b98481ed (patch)
tree9e7d5385cc1f500fd3ddc3f5983760d630647ffb /ext/mysqlnd/mysqlnd_auth.c
parente88c7bf5c7b0d97a43ef8356e5754008b35a8652 (diff)
parentdb08ef0d3274b239a6b9e68d71d02bb6acb71d82 (diff)
downloadphp-git-e9c2dec7205503d786ff3a6b2b30afd9b98481ed.tar.gz
Merge branch 'PHP-7.4'
* PHP-7.4: Fix RSA memory leak in mysqlnd auth
Diffstat (limited to 'ext/mysqlnd/mysqlnd_auth.c')
-rw-r--r--ext/mysqlnd/mysqlnd_auth.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ext/mysqlnd/mysqlnd_auth.c b/ext/mysqlnd/mysqlnd_auth.c
index f8791b08ce..7ab8295727 100644
--- a/ext/mysqlnd/mysqlnd_auth.c
+++ b/ext/mysqlnd/mysqlnd_auth.c
@@ -726,6 +726,7 @@ mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_pub
*/
if (server_public_key_len <= passwd_len + 41) {
/* password message is to long */
+ RSA_free(server_public_key);
SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
DBG_ERR("password is too long");
DBG_RETURN(NULL);
@@ -1016,6 +1017,7 @@ mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t serv
*/
if (server_public_key_len <= passwd_len + 41) {
/* password message is to long */
+ RSA_free(server_public_key);
SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long");
DBG_ERR("password is too long");
DBG_RETURN(0);
@@ -1023,6 +1025,7 @@ mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t serv
*crypted = emalloc(server_public_key_len);
RSA_public_encrypt(passwd_len + 1, (zend_uchar *) xor_str, *crypted, server_public_key, RSA_PKCS1_OAEP_PADDING);
+ RSA_free(server_public_key);
DBG_RETURN(server_public_key_len);
}
/* }}} */