diff options
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: packet.c,v 1.270 2018/05/25 03:20:59 dtucker Exp $ */ | 1 | /* $OpenBSD: packet.c,v 1.271 2018/06/01 04:05:29 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 |
@@ -418,13 +418,16 @@ ssh_packet_start_discard(struct ssh *ssh, struct sshenc *enc, | |||
418 | int | 418 | int |
419 | ssh_packet_connection_is_on_socket(struct ssh *ssh) | 419 | ssh_packet_connection_is_on_socket(struct ssh *ssh) |
420 | { | 420 | { |
421 | struct session_state *state = ssh->state; | 421 | struct session_state *state; |
422 | struct sockaddr_storage from, to; | 422 | struct sockaddr_storage from, to; |
423 | socklen_t fromlen, tolen; | 423 | socklen_t fromlen, tolen; |
424 | 424 | ||
425 | if (state->connection_in == -1 || state->connection_out == -1) | 425 | if (ssh == NULL || ssh->state == NULL) |
426 | return 0; | 426 | return 0; |
427 | 427 | ||
428 | state = ssh->state; | ||
429 | if (state->connection_in == -1 || state->connection_out == -1) | ||
430 | return 0; | ||
428 | /* filedescriptors in and out are the same, so it's a socket */ | 431 | /* filedescriptors in and out are the same, so it's a socket */ |
429 | if (state->connection_in == state->connection_out) | 432 | if (state->connection_in == state->connection_out) |
430 | return 1; | 433 | return 1; |
@@ -508,11 +511,12 @@ ssh_packet_get_connection_out(struct ssh *ssh) | |||
508 | const char * | 511 | const char * |
509 | ssh_remote_ipaddr(struct ssh *ssh) | 512 | ssh_remote_ipaddr(struct ssh *ssh) |
510 | { | 513 | { |
511 | const int sock = ssh->state->connection_in; | 514 | int sock; |
512 | 515 | ||
513 | /* Check whether we have cached the ipaddr. */ | 516 | /* Check whether we have cached the ipaddr. */ |
514 | if (ssh->remote_ipaddr == NULL) { | 517 | if (ssh->remote_ipaddr == NULL) { |
515 | if (ssh_packet_connection_is_on_socket(ssh)) { | 518 | if (ssh_packet_connection_is_on_socket(ssh)) { |
519 | sock = ssh->state->connection_in; | ||
516 | ssh->remote_ipaddr = get_peer_ipaddr(sock); | 520 | ssh->remote_ipaddr = get_peer_ipaddr(sock); |
517 | ssh->remote_port = get_peer_port(sock); | 521 | ssh->remote_port = get_peer_port(sock); |
518 | ssh->local_ipaddr = get_local_ipaddr(sock); | 522 | ssh->local_ipaddr = get_local_ipaddr(sock); |