mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-27 15:54:22 +02:00
upstream commit
Some packet error messages show the address of the peer, but might be generated after the socket to the peer has suffered a TCP reset. In these cases, getpeername() won't work so cache the address earlier. spotted in the wild via deraadt@ and tedu@
This commit is contained in:
parent
4af1709cf7
commit
d4c0295d1a
12
packet.c
12
packet.c
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: packet.c,v 1.206 2015/02/09 23:22:37 jsg Exp $ */
|
/* $OpenBSD: packet.c,v 1.207 2015/02/11 01:20:38 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
@ -290,11 +290,15 @@ ssh_packet_set_connection(struct ssh *ssh, int fd_in, int fd_out)
|
|||||||
(r = cipher_init(&state->receive_context, none,
|
(r = cipher_init(&state->receive_context, none,
|
||||||
(const u_char *)"", 0, NULL, 0, CIPHER_DECRYPT)) != 0) {
|
(const u_char *)"", 0, NULL, 0, CIPHER_DECRYPT)) != 0) {
|
||||||
error("%s: cipher_init failed: %s", __func__, ssh_err(r));
|
error("%s: cipher_init failed: %s", __func__, ssh_err(r));
|
||||||
free(ssh);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
state->newkeys[MODE_IN] = state->newkeys[MODE_OUT] = NULL;
|
state->newkeys[MODE_IN] = state->newkeys[MODE_OUT] = NULL;
|
||||||
deattack_init(&state->deattack);
|
deattack_init(&state->deattack);
|
||||||
|
/*
|
||||||
|
* Cache the IP address of the remote connection for use in error
|
||||||
|
* messages that might be generated after the connection has closed.
|
||||||
|
*/
|
||||||
|
(void)ssh_remote_ipaddr(ssh);
|
||||||
return ssh;
|
return ssh;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1274,10 +1278,8 @@ ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
|
|||||||
* Since we are blocking, ensure that all written packets have
|
* Since we are blocking, ensure that all written packets have
|
||||||
* been sent.
|
* been sent.
|
||||||
*/
|
*/
|
||||||
if ((r = ssh_packet_write_wait(ssh)) != 0) {
|
if ((r = ssh_packet_write_wait(ssh)) != 0)
|
||||||
free(setp);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
|
||||||
|
|
||||||
/* Stay in the loop until we have received a complete packet. */
|
/* Stay in the loop until we have received a complete packet. */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user