Bug 160 - fixed memory leaks with telnetd and debug CLI
This commit is contained in:
@ -179,6 +179,7 @@ GWBUF *
|
|||||||
gwbuf_consume(GWBUF *head, unsigned int length)
|
gwbuf_consume(GWBUF *head, unsigned int length)
|
||||||
{
|
{
|
||||||
GWBUF *rval = head;
|
GWBUF *rval = head;
|
||||||
|
|
||||||
CHK_GWBUF(head);
|
CHK_GWBUF(head);
|
||||||
GWBUF_CONSUME(head, length);
|
GWBUF_CONSUME(head, length);
|
||||||
if (GWBUF_EMPTY(head))
|
if (GWBUF_EMPTY(head))
|
||||||
|
|||||||
@ -167,7 +167,7 @@ char *password, *t;
|
|||||||
telnetd->state = TELNETD_STATE_PASSWD;
|
telnetd->state = TELNETD_STATE_PASSWD;
|
||||||
dcb_printf(dcb, "Password: ");
|
dcb_printf(dcb, "Password: ");
|
||||||
telnetd_echo(dcb, 0);
|
telnetd_echo(dcb, 0);
|
||||||
GWBUF_CONSUME(head, GWBUF_LENGTH(head));
|
gwbuf_consume(head, GWBUF_LENGTH(head));
|
||||||
break;
|
break;
|
||||||
case TELNETD_STATE_PASSWD:
|
case TELNETD_STATE_PASSWD:
|
||||||
password = strndup(GWBUF_DATA(head), GWBUF_LENGTH(head));
|
password = strndup(GWBUF_DATA(head), GWBUF_LENGTH(head));
|
||||||
@ -186,8 +186,9 @@ char *password, *t;
|
|||||||
dcb_printf(dcb, "\n\rLogin incorrect\n\rLogin: ");
|
dcb_printf(dcb, "\n\rLogin incorrect\n\rLogin: ");
|
||||||
telnetd_echo(dcb, 1);
|
telnetd_echo(dcb, 1);
|
||||||
telnetd->state = TELNETD_STATE_LOGIN;
|
telnetd->state = TELNETD_STATE_LOGIN;
|
||||||
|
free(telnetd->username);
|
||||||
}
|
}
|
||||||
GWBUF_CONSUME(head, GWBUF_LENGTH(head));
|
gwbuf_consume(head, GWBUF_LENGTH(head));
|
||||||
free(password);
|
free(password);
|
||||||
break;
|
break;
|
||||||
case TELNETD_STATE_DATA:
|
case TELNETD_STATE_DATA:
|
||||||
@ -195,6 +196,11 @@ char *password, *t;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Force the free of the buffer header
|
||||||
|
gwbuf_consume(head, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
|
|||||||
@ -208,10 +208,17 @@ CLI_SESSION *session = (CLI_SESSION *)router_session;
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free a debugcli session
|
||||||
|
*
|
||||||
|
* @param router_instance The router session
|
||||||
|
* @param router_client_session The router session as returned from newSession
|
||||||
|
*/
|
||||||
static void freeSession(
|
static void freeSession(
|
||||||
ROUTER* router_instance,
|
ROUTER* router_instance,
|
||||||
void* router_client_session)
|
void* router_client_session)
|
||||||
{
|
{
|
||||||
|
free(router_client_session);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user