summaryrefslogtreecommitdiff
path: root/packet.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2020-01-30 07:20:05 +0000
committerDamien Miller <djm@mindrot.org>2020-01-30 18:22:34 +1100
commitdce74eab0c0f9010dc84c62500a17771d0131ff3 (patch)
treeb627f9c1db439625ef221b2ffb7b5c43fcb41744 /packet.c
parent14ef4efe2bf4180e085ea6738fdbebc199458b0c (diff)
upstream: have sshpkt_fatal() save/restore errno before we
potentially call strerror() (via ssh_err()); ok dtucker OpenBSD-Commit-ID: 5590df31d21405498c848245b85c24acb84ad787
Diffstat (limited to 'packet.c')
-rw-r--r--packet.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/packet.c b/packet.c
index 38d3ea239..6d3e9172d 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.c,v 1.289 2020/01/23 10:53:04 dtucker Exp $ */ 1/* $OpenBSD: packet.c,v 1.290 2020/01/30 07:20:05 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
@@ -1850,6 +1850,7 @@ static void
1850sshpkt_vfatal(struct ssh *ssh, int r, const char *fmt, va_list ap) 1850sshpkt_vfatal(struct ssh *ssh, int r, const char *fmt, va_list ap)
1851{ 1851{
1852 char *tag = NULL, remote_id[512]; 1852 char *tag = NULL, remote_id[512];
1853 int oerrno = errno;
1853 1854
1854 sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id)); 1855 sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id));
1855 1856
@@ -1877,6 +1878,7 @@ sshpkt_vfatal(struct ssh *ssh, int r, const char *fmt, va_list ap)
1877 case SSH_ERR_NO_HOSTKEY_ALG_MATCH: 1878 case SSH_ERR_NO_HOSTKEY_ALG_MATCH:
1878 if (ssh && ssh->kex && ssh->kex->failed_choice) { 1879 if (ssh && ssh->kex && ssh->kex->failed_choice) {
1879 ssh_packet_clear_keys(ssh); 1880 ssh_packet_clear_keys(ssh);
1881 errno = oerrno;
1880 logdie("Unable to negotiate with %s: %s. " 1882 logdie("Unable to negotiate with %s: %s. "
1881 "Their offer: %s", remote_id, ssh_err(r), 1883 "Their offer: %s", remote_id, ssh_err(r),
1882 ssh->kex->failed_choice); 1884 ssh->kex->failed_choice);
@@ -1889,6 +1891,7 @@ sshpkt_vfatal(struct ssh *ssh, int r, const char *fmt, va_list ap)
1889 __func__); 1891 __func__);
1890 } 1892 }
1891 ssh_packet_clear_keys(ssh); 1893 ssh_packet_clear_keys(ssh);
1894 errno = oerrno;
1892 logdie("%s%sConnection %s %s: %s", 1895 logdie("%s%sConnection %s %s: %s",
1893 tag != NULL ? tag : "", tag != NULL ? ": " : "", 1896 tag != NULL ? tag : "", tag != NULL ? ": " : "",
1894 ssh->state->server_side ? "from" : "to", 1897 ssh->state->server_side ? "from" : "to",