From 4d28fa78abce2890e136281950633fae2066cc29 Mon Sep 17 00:00:00 2001 From: "deraadt@openbsd.org" Date: Fri, 28 Jun 2019 13:35:04 +0000 Subject: upstream: When system calls indicate an error they return -1, not some arbitrary value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future. OpenBSD-Commit-ID: 48081f00db7518e3b712a49dca06efc2a5428075 --- monitor.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'monitor.c') diff --git a/monitor.c b/monitor.c index 60e529444..96d10913c 100644 --- a/monitor.c +++ b/monitor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.c,v 1.197 2019/01/21 10:38:54 djm Exp $ */ +/* $OpenBSD: monitor.c,v 1.198 2019/06/28 13:35:04 deraadt Exp $ */ /* * Copyright 2002 Niels Provos * Copyright 2002 Markus Friedl @@ -1470,7 +1470,7 @@ mm_record_login(struct ssh *ssh, Session *s, struct passwd *pw) fromlen = sizeof(from); if (ssh_packet_connection_is_on_socket(ssh)) { if (getpeername(ssh_packet_get_connection_in(ssh), - (struct sockaddr *)&from, &fromlen) < 0) { + (struct sockaddr *)&from, &fromlen) == -1) { debug("getpeername: %.100s", strerror(errno)); cleanup_exit(255); } @@ -1538,7 +1538,7 @@ mm_answer_pty(struct ssh *ssh, int sock, struct sshbuf *m) fatal("%s: send fds failed", __func__); /* make sure nothing uses fd 0 */ - if ((fd0 = open(_PATH_DEVNULL, O_RDONLY)) < 0) + if ((fd0 = open(_PATH_DEVNULL, O_RDONLY)) == -1) fatal("%s: open(/dev/null): %s", __func__, strerror(errno)); if (fd0 != 0) error("%s: fd0 %d != 0", __func__, fd0); @@ -1730,9 +1730,9 @@ monitor_openfds(struct monitor *mon, int do_logfds) if (socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) fatal("%s: socketpair: %s", __func__, strerror(errno)); #ifdef SO_ZEROIZE - if (setsockopt(pair[0], SOL_SOCKET, SO_ZEROIZE, &on, sizeof(on)) < 0) + if (setsockopt(pair[0], SOL_SOCKET, SO_ZEROIZE, &on, sizeof(on)) == -1) error("setsockopt SO_ZEROIZE(0): %.100s", strerror(errno)); - if (setsockopt(pair[1], SOL_SOCKET, SO_ZEROIZE, &on, sizeof(on)) < 0) + if (setsockopt(pair[1], SOL_SOCKET, SO_ZEROIZE, &on, sizeof(on)) == -1) error("setsockopt SO_ZEROIZE(1): %.100s", strerror(errno)); #endif FD_CLOSEONEXEC(pair[0]); -- cgit v1.2.3 From cfc1897a2002ec6c4dc879b24e8b3153c87ea2cf Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Wed, 9 Oct 2019 09:06:35 +1100 Subject: wrap stdint.h include in HAVE_STDINT_H make the indenting a little more consistent too.. Fixes Solaris 2.6; reported by Tom G. Christensen --- channels.c | 2 +- monitor.c | 2 +- scp.c | 2 +- ssh-keygen.c | 4 +++- sshbuf-getput-basic.c | 4 +++- sshbuf-misc.c | 2 +- xmalloc.c | 2 +- xmss_commons.c | 2 +- xmss_fast.c | 2 +- xmss_hash.c | 2 +- xmss_hash_address.c | 2 +- xmss_wots.c | 2 +- 12 files changed, 16 insertions(+), 12 deletions(-) (limited to 'monitor.c') diff --git a/channels.c b/channels.c index 47521d3e7..0f45aee4e 100644 --- a/channels.c +++ b/channels.c @@ -59,7 +59,7 @@ #include #include #ifdef HAVE_STDINT_H - #include +# include #endif #include #include diff --git a/monitor.c b/monitor.c index 96d10913c..5076a74ff 100644 --- a/monitor.c +++ b/monitor.c @@ -40,7 +40,7 @@ #include #include #ifdef HAVE_STDINT_H -#include +# include #endif #include #include diff --git a/scp.c b/scp.c index 84a76d0b8..0348d0673 100644 --- a/scp.c +++ b/scp.c @@ -101,7 +101,7 @@ #include #include #ifdef HAVE_STDINT_H -#include +# include #endif #include #include diff --git a/ssh-keygen.c b/ssh-keygen.c index 85fb4424f..8c829cad6 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c @@ -24,7 +24,9 @@ #include "openbsd-compat/openssl-compat.h" #endif -#include +#ifdef HAVE_STDINT_H +# include +#endif #include #include #include diff --git a/sshbuf-getput-basic.c b/sshbuf-getput-basic.c index ffa20a02c..d401a7265 100644 --- a/sshbuf-getput-basic.c +++ b/sshbuf-getput-basic.c @@ -24,7 +24,9 @@ #include #include #include -#include +#ifdef HAVE_STDINT_H +# include +#endif #include "ssherr.h" #include "sshbuf.h" diff --git a/sshbuf-misc.c b/sshbuf-misc.c index 65987e251..a73f008b0 100644 --- a/sshbuf-misc.c +++ b/sshbuf-misc.c @@ -23,7 +23,7 @@ #include #include #ifdef HAVE_STDINT_H -#include +# include #endif #include #include diff --git a/xmalloc.c b/xmalloc.c index dc22757b0..9cd0127dd 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -17,7 +17,7 @@ #include #ifdef HAVE_STDINT_H -#include +# include #endif #include #include diff --git a/xmss_commons.c b/xmss_commons.c index 59486aead..8d6b80b6e 100644 --- a/xmss_commons.c +++ b/xmss_commons.c @@ -13,7 +13,7 @@ Public domain. #include #include #ifdef HAVE_STDINT_H -#include +# include #endif void to_byte(unsigned char *out, unsigned long long in, uint32_t bytes) diff --git a/xmss_fast.c b/xmss_fast.c index e37447f60..421b39a37 100644 --- a/xmss_fast.c +++ b/xmss_fast.c @@ -12,7 +12,7 @@ Public domain. #include #include #ifdef HAVE_STDINT_H -#include +# include #endif #include "xmss_fast.h" diff --git a/xmss_hash.c b/xmss_hash.c index b9eee7cff..50a577943 100644 --- a/xmss_hash.c +++ b/xmss_hash.c @@ -15,7 +15,7 @@ Public domain. #include #ifdef HAVE_STDINT_H -#include +# include #endif #include #include diff --git a/xmss_hash_address.c b/xmss_hash_address.c index c6c1347e9..2702c4562 100644 --- a/xmss_hash_address.c +++ b/xmss_hash_address.c @@ -9,7 +9,7 @@ Public domain. #ifdef WITH_XMSS #ifdef HAVE_STDINT_H -#include +# include #endif #include "xmss_hash_address.h" /* prototypes */ diff --git a/xmss_wots.c b/xmss_wots.c index ed904cd75..993e661f6 100644 --- a/xmss_wots.c +++ b/xmss_wots.c @@ -11,7 +11,7 @@ Public domain. #include #ifdef HAVE_STDINT_H -#include +# include #endif #include #include "xmss_commons.h" -- cgit v1.2.3 From e827aedf8818e75c0016b47ed8fc231427457c43 Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Mon, 7 Oct 2019 23:10:38 +0000 Subject: upstream: reversed test yielded incorrect debug message OpenBSD-Commit-ID: 78bb512d04cfc238adb2c5b7504ac93eecf523b3 --- monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'monitor.c') diff --git a/monitor.c b/monitor.c index 5076a74ff..00af44f98 100644 --- a/monitor.c +++ b/monitor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.c,v 1.198 2019/06/28 13:35:04 deraadt Exp $ */ +/* $OpenBSD: monitor.c,v 1.199 2019/10/07 23:10:38 djm Exp $ */ /* * Copyright 2002 Niels Provos * Copyright 2002 Markus Friedl @@ -692,7 +692,7 @@ mm_answer_sign(struct ssh *ssh, int sock, struct sshbuf *m) fatal("%s: no hostkey from index %d", __func__, keyid); debug3("%s: %s signature %p(%zu)", __func__, - is_proof ? "KEX" : "hostkey proof", signature, siglen); + is_proof ? "hostkey proof" : "KEX", signature, siglen); sshbuf_reset(m); if ((r = sshbuf_put_string(m, signature, siglen)) != 0) -- cgit v1.2.3