diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-03-23 16:31:45 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-03-23 16:32:52 +0100 |
commit | 0afdf194f0b2b313605516f05512e45cc50e87c5 (patch) | |
tree | 17fccd47f459cfaeb44624853a6ef5a8cab848dc | |
parent | efbc962c924b00dc5083362a827c9d70fb32fe4d (diff) | |
download | php-git-0afdf194f0b2b313605516f05512e45cc50e87c5.tar.gz |
Fix leak on Windows as well
Cf. <http://git.php.net/?p=php-src.git;a=commit;h=db08ef0d3274b239a6b9e68d71d02bb6acb71d82>
-rw-r--r-- | ext/mysqlnd/mysqlnd_auth.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/ext/mysqlnd/mysqlnd_auth.c b/ext/mysqlnd/mysqlnd_auth.c index fa8c709516..73a405863e 100644 --- a/ext/mysqlnd/mysqlnd_auth.c +++ b/ext/mysqlnd/mysqlnd_auth.c @@ -809,6 +809,7 @@ mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_pub */ if ((size_t) server_public_key_len <= passwd_len + 41) { /* password message is to long */ + BCryptDestroyKey((BCRYPT_KEY_HANDLE) 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); @@ -818,6 +819,7 @@ mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_pub ret = malloc(*auth_data_len); if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info, NULL, 0, ret, server_public_key_len, &server_public_key_len, BCRYPT_PAD_OAEP)) { + BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key); DBG_RETURN(0); } BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key); @@ -1057,6 +1059,7 @@ mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t serv */ if ((size_t) server_public_key_len <= passwd_len + 41) { /* password message is to long */ + BCryptDestroyKey((BCRYPT_KEY_HANDLE) 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); @@ -1065,8 +1068,10 @@ mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t serv *crypted = emalloc(server_public_key_len); if (BCryptEncrypt((BCRYPT_KEY_HANDLE) server_public_key, xor_str, passwd_len + 1, &padding_info, NULL, 0, *crypted, server_public_key_len, &server_public_key_len, BCRYPT_PAD_OAEP)) { + BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key); DBG_RETURN(0); } + BCryptDestroyKey((BCRYPT_KEY_HANDLE) server_public_key); DBG_RETURN(server_public_key_len); } /* }}} */ |