openssh/openssh-7.2p2-audit_fixes.patch
2017-12-01 15:03:13 +00:00

36 lines
1.1 KiB
Diff

# HG changeset patch
# Parent fdc9167221e501a9f4db5343cf8cadc31e13fd56
Various auditing fixes to be merged into the RH-originated patch.
diff --git a/openssh-7.2p2/packet.c b/openssh-7.2p2/packet.c
--- a/openssh-7.2p2/packet.c
+++ b/openssh-7.2p2/packet.c
@@ -371,20 +371,26 @@ ssh_packet_start_discard(struct ssh *ssh
return 0;
}
/* Returns 1 if remote host is connected via socket, 0 if not. */
int
ssh_packet_connection_is_on_socket(struct ssh *ssh)
{
- struct session_state *state = ssh->state;
+ struct session_state *state;
struct sockaddr_storage from, to;
socklen_t fromlen, tolen;
+ /* auditing might get here without valid connection structure when
+ * destroying sensitive data on exit and thus aborting disgracefully */
+ if ((!ssh) || (!(ssh->state)))
+ return 0;
+ state = ssh->state;
+
/* filedescriptors in and out are the same, so it's a socket */
if (state->connection_in == state->connection_out)
return 1;
fromlen = sizeof(from);
memset(&from, 0, sizeof(from));
if (getpeername(state->connection_in, (struct sockaddr *)&from,
&fromlen) < 0)
return 0;