From 2499378af916a9add8304082e6902fe5a73d4aa3 Mon Sep 17 00:00:00 2001 From: Mark Riddoch Date: Wed, 21 Aug 2013 12:06:31 +0200 Subject: [PATCH] Bug 160 - fixed freeing of username --- server/modules/protocol/telnetd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/modules/protocol/telnetd.c b/server/modules/protocol/telnetd.c index 672991a53..7a9d0f1d8 100644 --- a/server/modules/protocol/telnetd.c +++ b/server/modules/protocol/telnetd.c @@ -147,7 +147,7 @@ char *password, *t; { unsigned char *ptr = GWBUF_DATA(head); ptr = GWBUF_DATA(head); - while (*ptr == TELNET_IAC) + while (GWBUF_LENGTH(head) && *ptr == TELNET_IAC) { telnetd_command(dcb, ptr + 1); GWBUF_CONSUME(head, 3); @@ -289,6 +289,7 @@ int n_connect = 0; n_connect++; ((TELNETD *)(client->protocol))->state = TELNETD_STATE_LOGIN; + ((TELNETD *)(client->protocol))->username = NULL; dcb_printf(client, "MaxScale login: "); client->state = DCB_STATE_POLLING; } @@ -306,6 +307,11 @@ int n_connect = 0; static int telnetd_close(DCB *dcb) { +TELNETD *telnetd = dcb->protocol; + + if (telnetd && telnetd->username) + free(telnetd->username); + dcb_close(dcb); return 0; }