summaryrefslogtreecommitdiff
path: root/clientloop.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 /clientloop.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 'clientloop.c')
-rw-r--r--clientloop.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/clientloop.c b/clientloop.c
index ccf8f4b8c..7f32871f8 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: clientloop.c,v 1.325 2019/06/26 22:29:43 dtucker Exp $ */ 1/* $OpenBSD: clientloop.c,v 1.326 2019/06/28 13:35:04 deraadt 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
@@ -561,7 +561,7 @@ client_wait_until_can_do_something(struct ssh *ssh,
561 } 561 }
562 562
563 ret = select((*maxfdp)+1, *readsetp, *writesetp, NULL, tvp); 563 ret = select((*maxfdp)+1, *readsetp, *writesetp, NULL, tvp);
564 if (ret < 0) { 564 if (ret == -1) {
565 /* 565 /*
566 * We have to clear the select masks, because we return. 566 * We have to clear the select masks, because we return.
567 * We have to return, because the mainloop checks for the flags 567 * We have to return, because the mainloop checks for the flags
@@ -644,11 +644,11 @@ client_process_net_input(struct ssh *ssh, fd_set *readset)
644 * There is a kernel bug on Solaris that causes select to 644 * There is a kernel bug on Solaris that causes select to
645 * sometimes wake up even though there is no data available. 645 * sometimes wake up even though there is no data available.
646 */ 646 */
647 if (len < 0 && 647 if (len == -1 &&
648 (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK)) 648 (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
649 len = 0; 649 len = 0;
650 650
651 if (len < 0) { 651 if (len == -1) {
652 /* 652 /*
653 * An error has encountered. Perhaps there is a 653 * An error has encountered. Perhaps there is a
654 * network problem. 654 * network problem.
@@ -1096,7 +1096,7 @@ process_escapes(struct ssh *ssh, Channel *c,
1096 1096
1097 /* Fork into background. */ 1097 /* Fork into background. */
1098 pid = fork(); 1098 pid = fork();
1099 if (pid < 0) { 1099 if (pid == -1) {
1100 error("fork: %.100s", strerror(errno)); 1100 error("fork: %.100s", strerror(errno));
1101 continue; 1101 continue;
1102 } 1102 }
@@ -2248,7 +2248,7 @@ client_session2_setup(struct ssh *ssh, int id, int want_tty, int want_subsystem,
2248 struct winsize ws; 2248 struct winsize ws;
2249 2249
2250 /* Store window size in the packet. */ 2250 /* Store window size in the packet. */
2251 if (ioctl(in_fd, TIOCGWINSZ, &ws) < 0) 2251 if (ioctl(in_fd, TIOCGWINSZ, &ws) == -1)
2252 memset(&ws, 0, sizeof(ws)); 2252 memset(&ws, 0, sizeof(ws));
2253 2253
2254 channel_request_start(ssh, id, "pty-req", 1); 2254 channel_request_start(ssh, id, "pty-req", 1);