Fix: accessed released memory in mysql_client.c where dcb->data was released in gw_mysql_do_authentication and accessed afterwards.

This commit is contained in:
VilhoRaatikka
2014-12-30 10:36:06 +02:00
parent c2cdbf40bc
commit df0b04a5c0
2 changed files with 14 additions and 10 deletions

View File

@ -437,8 +437,6 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) {
/* Detect now if there are enough bytes to continue */
if (client_auth_packet_size < (4 + 4 + 4 + 1 + 23))
{
free(dcb->data);
dcb->data = NULL;
return 1;
}
@ -457,8 +455,6 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) {
if (username == NULL)
{
free(dcb->data);
dcb->data = NULL;
return 1;
}
@ -529,8 +525,7 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) {
}
else
{
free(dcb->data);
dcb->data = NULL;
return 1;
}
/* let's free the auth_token now */
@ -723,7 +718,12 @@ int gw_read_client_event(
"state = MYSQL_AUTH_FAILED.",
protocol->owner_dcb->fd,
pthread_self())));
/**
* Release MYSQL_session since it is not used anymore.
*/
free(dcb->data);
dcb->data = NULL;
dcb_close(dcb);
}
read_buffer = gwbuf_consume(read_buffer, nbytes_read);