mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-26 09:42:25 +00:00
Memory management fixes. Fixed a segfault in SSH1 compression
cleanup noticed by Gerhard Wiesinger, and also fixed some memory leaks spotted by valgrind while debugging same. [originally from svn r3726]
This commit is contained in:
parent
5a11f18569
commit
33a59e78f1
16
ssh.c
16
ssh.c
@ -2767,6 +2767,7 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
if (s->authed)
|
if (s->authed)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
sfree(s->response);
|
||||||
}
|
}
|
||||||
if (s->authed)
|
if (s->authed)
|
||||||
break;
|
break;
|
||||||
@ -4922,6 +4923,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
if (s->authed)
|
if (s->authed)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
sfree(s->response);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s->method && s->can_pubkey && s->publickey_blob
|
if (!s->method && s->can_pubkey && s->publickey_blob
|
||||||
@ -6264,10 +6266,18 @@ static void ssh_free(void *handle)
|
|||||||
ssh->csmac->free_context(ssh->cs_mac_ctx);
|
ssh->csmac->free_context(ssh->cs_mac_ctx);
|
||||||
if (ssh->sc_mac_ctx)
|
if (ssh->sc_mac_ctx)
|
||||||
ssh->scmac->free_context(ssh->sc_mac_ctx);
|
ssh->scmac->free_context(ssh->sc_mac_ctx);
|
||||||
if (ssh->cs_comp_ctx)
|
if (ssh->cs_comp_ctx) {
|
||||||
|
if (ssh->cscomp)
|
||||||
ssh->cscomp->compress_cleanup(ssh->cs_comp_ctx);
|
ssh->cscomp->compress_cleanup(ssh->cs_comp_ctx);
|
||||||
if (ssh->sc_comp_ctx)
|
else
|
||||||
ssh->sccomp->compress_cleanup(ssh->sc_comp_ctx);
|
zlib_compress_cleanup(ssh->cs_comp_ctx);
|
||||||
|
}
|
||||||
|
if (ssh->sc_comp_ctx) {
|
||||||
|
if (ssh->sccomp)
|
||||||
|
ssh->sccomp->decompress_cleanup(ssh->sc_comp_ctx);
|
||||||
|
else
|
||||||
|
zlib_decompress_cleanup(ssh->sc_comp_ctx);
|
||||||
|
}
|
||||||
if (ssh->kex_ctx)
|
if (ssh->kex_ctx)
|
||||||
dh_cleanup(ssh->kex_ctx);
|
dh_cleanup(ssh->kex_ctx);
|
||||||
sfree(ssh->savedhost);
|
sfree(ssh->savedhost);
|
||||||
|
@ -602,6 +602,8 @@ void zlib_compress_cleanup(void *handle)
|
|||||||
{
|
{
|
||||||
struct LZ77Context *ectx = (struct LZ77Context *)handle;
|
struct LZ77Context *ectx = (struct LZ77Context *)handle;
|
||||||
sfree(ectx->userdata);
|
sfree(ectx->userdata);
|
||||||
|
sfree(ectx->ictx);
|
||||||
|
sfree(ectx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -970,6 +972,8 @@ void zlib_decompress_cleanup(void *handle)
|
|||||||
zlib_freetable(&dctx->currdisttable);
|
zlib_freetable(&dctx->currdisttable);
|
||||||
if (dctx->lenlentable)
|
if (dctx->lenlentable)
|
||||||
zlib_freetable(&dctx->lenlentable);
|
zlib_freetable(&dctx->lenlentable);
|
||||||
|
zlib_freetable(&dctx->staticlentable);
|
||||||
|
zlib_freetable(&dctx->staticdisttable);
|
||||||
sfree(dctx);
|
sfree(dctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user