Bug 160 - fixed freeing of username

This commit is contained in:
Mark Riddoch
2013-08-21 12:06:31 +02:00
parent 73ffa5a648
commit 2499378af9

View File

@ -147,7 +147,7 @@ char *password, *t;
{ {
unsigned char *ptr = GWBUF_DATA(head); unsigned char *ptr = GWBUF_DATA(head);
ptr = GWBUF_DATA(head); ptr = GWBUF_DATA(head);
while (*ptr == TELNET_IAC) while (GWBUF_LENGTH(head) && *ptr == TELNET_IAC)
{ {
telnetd_command(dcb, ptr + 1); telnetd_command(dcb, ptr + 1);
GWBUF_CONSUME(head, 3); GWBUF_CONSUME(head, 3);
@ -289,6 +289,7 @@ int n_connect = 0;
n_connect++; n_connect++;
((TELNETD *)(client->protocol))->state = TELNETD_STATE_LOGIN; ((TELNETD *)(client->protocol))->state = TELNETD_STATE_LOGIN;
((TELNETD *)(client->protocol))->username = NULL;
dcb_printf(client, "MaxScale login: "); dcb_printf(client, "MaxScale login: ");
client->state = DCB_STATE_POLLING; client->state = DCB_STATE_POLLING;
} }
@ -306,6 +307,11 @@ int n_connect = 0;
static int static int
telnetd_close(DCB *dcb) telnetd_close(DCB *dcb)
{ {
TELNETD *telnetd = dcb->protocol;
if (telnetd && telnetd->username)
free(telnetd->username);
dcb_close(dcb); dcb_close(dcb);
return 0; return 0;
} }