1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-02-03 21:52:24 +00:00

Fix use-after-free on a network error.

When any BPP calls ssh_remote_error or ssh_remote_eof, it triggers an
immediate cleanup of the BPP itself - so on return from one of those
functions we should avoid going straight to the crFinish macro,
because that will write to s->crState, which no longer exists.
This commit is contained in:
Simon Tatham 2018-09-28 11:26:26 +01:00
parent ed0104c2fe
commit e857e43361
4 changed files with 4 additions and 0 deletions

View File

@ -245,6 +245,7 @@ static void ssh1_bpp_handle_input(BinaryPacketProtocol *bpp)
} else { } else {
ssh_remote_eof(s->bpp.ssh, "Server closed network connection"); ssh_remote_eof(s->bpp.ssh, "Server closed network connection");
} }
return; /* avoid touching s now it's been freed */
crFinishV; crFinishV;
} }

View File

@ -136,6 +136,7 @@ static void ssh2_bare_bpp_handle_input(BinaryPacketProtocol *bpp)
} else { } else {
ssh_remote_eof(s->bpp.ssh, "Server closed network connection"); ssh_remote_eof(s->bpp.ssh, "Server closed network connection");
} }
return; /* avoid touching s now it's been freed */
crFinishV; crFinishV;
} }

View File

@ -516,6 +516,7 @@ static void ssh2_bpp_handle_input(BinaryPacketProtocol *bpp)
} else { } else {
ssh_remote_eof(s->bpp.ssh, "Server closed network connection"); ssh_remote_eof(s->bpp.ssh, "Server closed network connection");
} }
return; /* avoid touching s now it's been freed */
crFinishV; crFinishV;
} }

View File

@ -396,6 +396,7 @@ void ssh_verstring_handle_input(BinaryPacketProtocol *bpp)
eof: eof:
ssh_remote_error(s->bpp.ssh, ssh_remote_error(s->bpp.ssh,
"Server unexpectedly closed network connection"); "Server unexpectedly closed network connection");
return; /* avoid touching s now it's been freed */
crFinishV; crFinishV;
} }