summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorderaadt@openbsd.org <deraadt@openbsd.org>2019-06-28 13:35:04 +0000
committerDamien Miller <djm@mindrot.org>2019-07-05 11:10:39 +1000
commit4d28fa78abce2890e136281950633fae2066cc29 (patch)
tree33226ec64ced661bb7e40005e30744b68fa59a80 /monitor.c
parente8c974043c1648eab0ad67a7ba6a3e444fe79d2d (diff)
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
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/monitor.c b/monitor.c
index 60e529444..96d10913c 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor.c,v 1.197 2019/01/21 10:38:54 djm Exp $ */ 1/* $OpenBSD: monitor.c,v 1.198 2019/06/28 13:35:04 deraadt Exp $ */
2/* 2/*
3 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 3 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4 * Copyright 2002 Markus Friedl <markus@openbsd.org> 4 * Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -1470,7 +1470,7 @@ mm_record_login(struct ssh *ssh, Session *s, struct passwd *pw)
1470 fromlen = sizeof(from); 1470 fromlen = sizeof(from);
1471 if (ssh_packet_connection_is_on_socket(ssh)) { 1471 if (ssh_packet_connection_is_on_socket(ssh)) {
1472 if (getpeername(ssh_packet_get_connection_in(ssh), 1472 if (getpeername(ssh_packet_get_connection_in(ssh),
1473 (struct sockaddr *)&from, &fromlen) < 0) { 1473 (struct sockaddr *)&from, &fromlen) == -1) {
1474 debug("getpeername: %.100s", strerror(errno)); 1474 debug("getpeername: %.100s", strerror(errno));
1475 cleanup_exit(255); 1475 cleanup_exit(255);
1476 } 1476 }
@@ -1538,7 +1538,7 @@ mm_answer_pty(struct ssh *ssh, int sock, struct sshbuf *m)
1538 fatal("%s: send fds failed", __func__); 1538 fatal("%s: send fds failed", __func__);
1539 1539
1540 /* make sure nothing uses fd 0 */ 1540 /* make sure nothing uses fd 0 */
1541 if ((fd0 = open(_PATH_DEVNULL, O_RDONLY)) < 0) 1541 if ((fd0 = open(_PATH_DEVNULL, O_RDONLY)) == -1)
1542 fatal("%s: open(/dev/null): %s", __func__, strerror(errno)); 1542 fatal("%s: open(/dev/null): %s", __func__, strerror(errno));
1543 if (fd0 != 0) 1543 if (fd0 != 0)
1544 error("%s: fd0 %d != 0", __func__, fd0); 1544 error("%s: fd0 %d != 0", __func__, fd0);
@@ -1730,9 +1730,9 @@ monitor_openfds(struct monitor *mon, int do_logfds)
1730 if (socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) 1730 if (socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1)
1731 fatal("%s: socketpair: %s", __func__, strerror(errno)); 1731 fatal("%s: socketpair: %s", __func__, strerror(errno));
1732#ifdef SO_ZEROIZE 1732#ifdef SO_ZEROIZE
1733 if (setsockopt(pair[0], SOL_SOCKET, SO_ZEROIZE, &on, sizeof(on)) < 0) 1733 if (setsockopt(pair[0], SOL_SOCKET, SO_ZEROIZE, &on, sizeof(on)) == -1)
1734 error("setsockopt SO_ZEROIZE(0): %.100s", strerror(errno)); 1734 error("setsockopt SO_ZEROIZE(0): %.100s", strerror(errno));
1735 if (setsockopt(pair[1], SOL_SOCKET, SO_ZEROIZE, &on, sizeof(on)) < 0) 1735 if (setsockopt(pair[1], SOL_SOCKET, SO_ZEROIZE, &on, sizeof(on)) == -1)
1736 error("setsockopt SO_ZEROIZE(1): %.100s", strerror(errno)); 1736 error("setsockopt SO_ZEROIZE(1): %.100s", strerror(errno));
1737#endif 1737#endif
1738 FD_CLOSEONEXEC(pair[0]); 1738 FD_CLOSEONEXEC(pair[0]);