[openssh-commits] [openssh] 02/04: upstream: have sshpkt_fatal() save/restore errno before we

git+noreply at mindrot.org git+noreply at mindrot.org
Thu Jan 30 18:22:41 AEDT 2020


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit dce74eab0c0f9010dc84c62500a17771d0131ff3
Author: djm at openbsd.org <djm at openbsd.org>
Date:   Thu Jan 30 07:20:05 2020 +0000

    upstream: have sshpkt_fatal() save/restore errno before we
    
    potentially call strerror() (via ssh_err()); ok dtucker
    
    OpenBSD-Commit-ID: 5590df31d21405498c848245b85c24acb84ad787
---
 packet.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/packet.c b/packet.c
index 38d3ea23..6d3e9172 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.289 2020/01/23 10:53:04 dtucker Exp $ */
+/* $OpenBSD: packet.c,v 1.290 2020/01/30 07:20:05 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo at cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -1850,6 +1850,7 @@ static void
 sshpkt_vfatal(struct ssh *ssh, int r, const char *fmt, va_list ap)
 {
 	char *tag = NULL, remote_id[512];
+	int oerrno = errno;
 
 	sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id));
 
@@ -1877,6 +1878,7 @@ sshpkt_vfatal(struct ssh *ssh, int r, const char *fmt, va_list ap)
 	case SSH_ERR_NO_HOSTKEY_ALG_MATCH:
 		if (ssh && ssh->kex && ssh->kex->failed_choice) {
 			ssh_packet_clear_keys(ssh);
+			errno = oerrno;
 			logdie("Unable to negotiate with %s: %s. "
 			    "Their offer: %s", remote_id, ssh_err(r),
 			    ssh->kex->failed_choice);
@@ -1889,6 +1891,7 @@ sshpkt_vfatal(struct ssh *ssh, int r, const char *fmt, va_list ap)
 			    __func__);
 		}
 		ssh_packet_clear_keys(ssh);
+		errno = oerrno;
 		logdie("%s%sConnection %s %s: %s",
 		    tag != NULL ? tag : "", tag != NULL ? ": " : "",
 		    ssh->state->server_side ? "from" : "to",

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list