diff options
author | djm@openbsd.org <djm@openbsd.org> | 2015-02-11 01:20:38 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2015-02-11 12:26:31 +1100 |
commit | d4c0295d1afc342057ba358237acad6be8af480b (patch) | |
tree | a4e5a1fa8079f713f6c29aedc7e3d9f2cc66faa4 /packet.c | |
parent | 4af1709cf774475ce5d1bc3ddcc165f6c222897d (diff) |
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@
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: packet.c,v 1.206 2015/02/09 23:22:37 jsg Exp $ */ | 1 | /* $OpenBSD: packet.c,v 1.207 2015/02/11 01:20:38 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * 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) | |||
290 | (r = cipher_init(&state->receive_context, none, | 290 | (r = cipher_init(&state->receive_context, none, |
291 | (const u_char *)"", 0, NULL, 0, CIPHER_DECRYPT)) != 0) { | 291 | (const u_char *)"", 0, NULL, 0, CIPHER_DECRYPT)) != 0) { |
292 | error("%s: cipher_init failed: %s", __func__, ssh_err(r)); | 292 | error("%s: cipher_init failed: %s", __func__, ssh_err(r)); |
293 | free(ssh); | ||
294 | return NULL; | 293 | return NULL; |
295 | } | 294 | } |
296 | state->newkeys[MODE_IN] = state->newkeys[MODE_OUT] = NULL; | 295 | state->newkeys[MODE_IN] = state->newkeys[MODE_OUT] = NULL; |
297 | deattack_init(&state->deattack); | 296 | deattack_init(&state->deattack); |
297 | /* | ||
298 | * Cache the IP address of the remote connection for use in error | ||
299 | * messages that might be generated after the connection has closed. | ||
300 | */ | ||
301 | (void)ssh_remote_ipaddr(ssh); | ||
298 | return ssh; | 302 | return ssh; |
299 | } | 303 | } |
300 | 304 | ||
@@ -1274,10 +1278,8 @@ ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p) | |||
1274 | * Since we are blocking, ensure that all written packets have | 1278 | * Since we are blocking, ensure that all written packets have |
1275 | * been sent. | 1279 | * been sent. |
1276 | */ | 1280 | */ |
1277 | if ((r = ssh_packet_write_wait(ssh)) != 0) { | 1281 | if ((r = ssh_packet_write_wait(ssh)) != 0) |
1278 | free(setp); | ||
1279 | return r; | 1282 | return r; |
1280 | } | ||
1281 | 1283 | ||
1282 | /* Stay in the loop until we have received a complete packet. */ | 1284 | /* Stay in the loop until we have received a complete packet. */ |
1283 | for (;;) { | 1285 | for (;;) { |