Skip to content

Commit

Permalink
Fixed leak in ma_tls_read/write
Browse files Browse the repository at this point in the history
  • Loading branch information
9EOR9 committed Jul 31, 2018
1 parent f69eaf0 commit f1fd014
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion libmariadb/mariadb_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,7 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
free(s_passwd);
free(s_db);

if (db && !(mysql->db= strdup(db)))
if (!mysql->db && db && !(mysql->db= strdup(db)))
{
SET_CLIENT_ERROR(mysql, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
rc= 1;
Expand Down
10 changes: 4 additions & 6 deletions libmariadb/secure/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,15 +719,14 @@ ssize_t ma_tls_write_async(MARIADB_PVIO *pvio,
ssize_t ma_tls_read(MARIADB_TLS *ctls, const uchar* buffer, size_t length)
{
ssize_t rc;
MYSQL *mysql= (MYSQL *)SSL_get_app_data(ctls->ssl);
MARIADB_PVIO *pvio= mysql->net.pvio;
MARIADB_PVIO *pvio= ctls->pvio;

while ((rc= SSL_read((SSL *)ctls->ssl, (void *)buffer, (int)length)) < 0)
{
int error= SSL_get_error((SSL *)ctls->ssl, rc);
if (error != SSL_ERROR_WANT_READ)
return rc;
if (pvio->methods->wait_io_or_timeout(pvio, TRUE, mysql->options.read_timeout) < 1)
if (pvio->methods->wait_io_or_timeout(pvio, TRUE, pvio->mysql->options.read_timeout) < 1)
return rc;
}
return rc;
Expand All @@ -736,15 +735,14 @@ ssize_t ma_tls_read(MARIADB_TLS *ctls, const uchar* buffer, size_t length)
ssize_t ma_tls_write(MARIADB_TLS *ctls, const uchar* buffer, size_t length)
{
ssize_t rc;
MYSQL *mysql= (MYSQL *)SSL_get_app_data(ctls->ssl);
MARIADB_PVIO *pvio= mysql->net.pvio;
MARIADB_PVIO *pvio= ctls->pvio;

while ((rc= SSL_write((SSL *)ctls->ssl, (void *)buffer, (int)length)) <= 0)
{
int error= SSL_get_error((SSL *)ctls->ssl, rc);
if (error != SSL_ERROR_WANT_WRITE)
return rc;
if (pvio->methods->wait_io_or_timeout(pvio, TRUE, mysql->options.write_timeout) < 1)
if (pvio->methods->wait_io_or_timeout(pvio, TRUE, pvio->mysql->options.write_timeout) < 1)
return rc;
}
return rc;
Expand Down
2 changes: 2 additions & 0 deletions unittest/libmariadb/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ static int test_auth256(MYSQL *my)
if (!mysql_client_find_plugin(mysql, "sha256_password", 3))
{
diag("sha256_password plugin not available");
mysql_close(mysql);
return SKIP;
}

Expand All @@ -1097,6 +1098,7 @@ static int test_auth256(MYSQL *my)
if (!num_rows)
{
diag("server doesn't support sha256 authentication");
mysql_close(mysql);
return SKIP;
}

Expand Down

0 comments on commit f1fd014

Please sign in to comment.