summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorderaadt <>2019-06-28 13:35:02 +0000
committerderaadt <>2019-06-28 13:35:02 +0000
commit6585927e66d9ab172754d95c4296dd4309a40512 (patch)
treebc969c069c7b769f2601db17f08bec99274202a5
parent74ff76124ba7a371400a9f60d5e33192a3732f03 (diff)
downloadopenbsd-6585927e66d9ab172754d95c4296dd4309a40512.tar.gz
openbsd-6585927e66d9ab172754d95c4296dd4309a40512.tar.bz2
openbsd-6585927e66d9ab172754d95c4296dd4309a40512.zip
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.
-rw-r--r--src/lib/libc/net/rcmdsh.c10
-rw-r--r--src/lib/libc/net/rresvport.c6
-rw-r--r--src/lib/libc/net/ruserok.c4
-rw-r--r--src/lib/libc/stdlib/malloc.c4
-rw-r--r--src/usr.bin/nc/netcat.c32
-rw-r--r--src/usr.bin/openssl/apps.c28
-rw-r--r--src/usr.bin/openssl/s_client.c6
-rw-r--r--src/usr.bin/openssl/s_server.c4
-rw-r--r--src/usr.bin/openssl/s_socket.c8
-rw-r--r--src/usr.sbin/ocspcheck/http.c10
10 files changed, 56 insertions, 56 deletions
diff --git a/src/lib/libc/net/rcmdsh.c b/src/lib/libc/net/rcmdsh.c
index b9cbd6d5d1..66caac3f3d 100644
--- a/src/lib/libc/net/rcmdsh.c
+++ b/src/lib/libc/net/rcmdsh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rcmdsh.c,v 1.19 2016/05/28 15:46:00 millert Exp $ */ 1/* $OpenBSD: rcmdsh.c,v 1.20 2019/06/28 13:32:42 deraadt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001, MagniComp 4 * Copyright (c) 2001, MagniComp
@@ -89,13 +89,13 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser,
89 } 89 }
90 90
91 /* Get a socketpair we'll use for stdin and stdout. */ 91 /* Get a socketpair we'll use for stdin and stdout. */
92 if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) < 0) { 92 if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) == -1) {
93 perror("rcmdsh: socketpair"); 93 perror("rcmdsh: socketpair");
94 return(-1); 94 return(-1);
95 } 95 }
96 96
97 cpid = fork(); 97 cpid = fork();
98 if (cpid < 0) { 98 if (cpid == -1) {
99 perror("rcmdsh: fork failed"); 99 perror("rcmdsh: fork failed");
100 return(-1); 100 return(-1);
101 } else if (cpid == 0) { 101 } else if (cpid == 0) {
@@ -103,13 +103,13 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser,
103 * Child. We use sp[1] to be stdin/stdout, and close sp[0]. 103 * Child. We use sp[1] to be stdin/stdout, and close sp[0].
104 */ 104 */
105 (void) close(sp[0]); 105 (void) close(sp[0]);
106 if (dup2(sp[1], 0) < 0 || dup2(0, 1) < 0) { 106 if (dup2(sp[1], 0) == -1 || dup2(0, 1) == -1) {
107 perror("rcmdsh: dup2 failed"); 107 perror("rcmdsh: dup2 failed");
108 _exit(255); 108 _exit(255);
109 } 109 }
110 /* Fork again to lose parent. */ 110 /* Fork again to lose parent. */
111 cpid = fork(); 111 cpid = fork();
112 if (cpid < 0) { 112 if (cpid == -1) {
113 perror("rcmdsh: fork to lose parent failed"); 113 perror("rcmdsh: fork to lose parent failed");
114 _exit(255); 114 _exit(255);
115 } 115 }
diff --git a/src/lib/libc/net/rresvport.c b/src/lib/libc/net/rresvport.c
index 6b45000f7b..72c27c3a3f 100644
--- a/src/lib/libc/net/rresvport.c
+++ b/src/lib/libc/net/rresvport.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rresvport.c,v 1.11 2015/09/12 14:56:50 guenther Exp $ */ 1/* $OpenBSD: rresvport.c,v 1.12 2019/06/28 13:32:42 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 1995, 1996, 1998 Theo de Raadt. All rights reserved. 3 * Copyright (c) 1995, 1996, 1998 Theo de Raadt. All rights reserved.
4 * Copyright (c) 1983, 1993, 1994 4 * Copyright (c) 1983, 1993, 1994
@@ -82,12 +82,12 @@ rresvport_af(int *alport, int af)
82 sa->sa_family = af; 82 sa->sa_family = af;
83 83
84 s = socket(af, SOCK_STREAM, 0); 84 s = socket(af, SOCK_STREAM, 0);
85 if (s < 0) 85 if (s == -1)
86 return (-1); 86 return (-1);
87 87
88 *portp = htons(*alport); 88 *portp = htons(*alport);
89 if (*alport < IPPORT_RESERVED - 1) { 89 if (*alport < IPPORT_RESERVED - 1) {
90 if (bind(s, sa, sa->sa_len) >= 0) 90 if (bind(s, sa, sa->sa_len) != -1)
91 return (s); 91 return (s);
92 if (errno != EADDRINUSE) { 92 if (errno != EADDRINUSE) {
93 (void)close(s); 93 (void)close(s);
diff --git a/src/lib/libc/net/ruserok.c b/src/lib/libc/net/ruserok.c
index cab6f96449..a399c013e2 100644
--- a/src/lib/libc/net/ruserok.c
+++ b/src/lib/libc/net/ruserok.c
@@ -131,11 +131,11 @@ again:
131 * user or root or if writeable by anyone but the owner, quit. 131 * user or root or if writeable by anyone but the owner, quit.
132 */ 132 */
133 cp = NULL; 133 cp = NULL;
134 if (lstat(pbuf, &sbuf) < 0) 134 if (lstat(pbuf, &sbuf) == -1)
135 cp = ".rhosts lstat failed"; 135 cp = ".rhosts lstat failed";
136 else if (!S_ISREG(sbuf.st_mode)) 136 else if (!S_ISREG(sbuf.st_mode))
137 cp = ".rhosts not regular file"; 137 cp = ".rhosts not regular file";
138 else if (fstat(fileno(hostf), &sbuf) < 0) 138 else if (fstat(fileno(hostf), &sbuf) == -1)
139 cp = ".rhosts fstat failed"; 139 cp = ".rhosts fstat failed";
140 else if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) 140 else if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid)
141 cp = "bad .rhosts owner"; 141 cp = "bad .rhosts owner";
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index f2e82679e9..7d49438b7b 100644
--- a/src/lib/libc/stdlib/malloc.c
+++ b/src/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: malloc.c,v 1.261 2019/05/23 06:43:18 otto Exp $ */ 1/* $OpenBSD: malloc.c,v 1.262 2019/06/28 13:32:42 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net> 3 * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net>
4 * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> 4 * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@@ -897,7 +897,7 @@ omalloc_make_chunks(struct dir_info *d, int bits, int listnum)
897 return NULL; 897 return NULL;
898 898
899 /* memory protect the page allocated in the malloc(0) case */ 899 /* memory protect the page allocated in the malloc(0) case */
900 if (bits == 0 && mprotect(pp, MALLOC_PAGESIZE, PROT_NONE) < 0) 900 if (bits == 0 && mprotect(pp, MALLOC_PAGESIZE, PROT_NONE) == -1)
901 goto err; 901 goto err;
902 902
903 bp = alloc_chunk_info(d, bits); 903 bp = alloc_chunk_info(d, bits);
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c
index 26288560b0..c2e769c4c0 100644
--- a/src/usr.bin/nc/netcat.c
+++ b/src/usr.bin/nc/netcat.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: netcat.c,v 1.204 2019/06/27 18:03:37 deraadt Exp $ */ 1/* $OpenBSD: netcat.c,v 1.205 2019/06/28 13:35:02 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> 3 * Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
4 * Copyright (c) 2015 Bob Beck. All rights reserved. 4 * Copyright (c) 2015 Bob Beck. All rights reserved.
@@ -568,7 +568,7 @@ main(int argc, char *argv[])
568 close(s); 568 close(s);
569 s = local_listen(host, uport, hints); 569 s = local_listen(host, uport, hints);
570 } 570 }
571 if (s < 0) 571 if (s == -1)
572 err(1, NULL); 572 err(1, NULL);
573 if (uflag && kflag) { 573 if (uflag && kflag) {
574 /* 574 /*
@@ -590,11 +590,11 @@ main(int argc, char *argv[])
590 len = sizeof(z); 590 len = sizeof(z);
591 rv = recvfrom(s, buf, sizeof(buf), MSG_PEEK, 591 rv = recvfrom(s, buf, sizeof(buf), MSG_PEEK,
592 (struct sockaddr *)&z, &len); 592 (struct sockaddr *)&z, &len);
593 if (rv < 0) 593 if (rv == -1)
594 err(1, "recvfrom"); 594 err(1, "recvfrom");
595 595
596 rv = connect(s, (struct sockaddr *)&z, len); 596 rv = connect(s, (struct sockaddr *)&z, len);
597 if (rv < 0) 597 if (rv == -1)
598 err(1, "connect"); 598 err(1, "connect");
599 599
600 if (vflag) 600 if (vflag)
@@ -628,7 +628,7 @@ main(int argc, char *argv[])
628 tls_free(tls_cctx); 628 tls_free(tls_cctx);
629 } 629 }
630 if (family == AF_UNIX && uflag) { 630 if (family == AF_UNIX && uflag) {
631 if (connect(s, NULL, 0) < 0) 631 if (connect(s, NULL, 0) == -1)
632 err(1, "connect"); 632 err(1, "connect");
633 } 633 }
634 634
@@ -739,7 +739,7 @@ unix_bind(char *path, int flags)
739 739
740 /* Create unix domain socket. */ 740 /* Create unix domain socket. */
741 if ((s = socket(AF_UNIX, flags | (uflag ? SOCK_DGRAM : SOCK_STREAM), 741 if ((s = socket(AF_UNIX, flags | (uflag ? SOCK_DGRAM : SOCK_STREAM),
742 0)) < 0) 742 0)) == -1)
743 return -1; 743 return -1;
744 744
745 memset(&s_un, 0, sizeof(struct sockaddr_un)); 745 memset(&s_un, 0, sizeof(struct sockaddr_un));
@@ -752,7 +752,7 @@ unix_bind(char *path, int flags)
752 return -1; 752 return -1;
753 } 753 }
754 754
755 if (bind(s, (struct sockaddr *)&s_un, sizeof(s_un)) < 0) { 755 if (bind(s, (struct sockaddr *)&s_un, sizeof(s_un)) == -1) {
756 save_errno = errno; 756 save_errno = errno;
757 close(s); 757 close(s);
758 errno = save_errno; 758 errno = save_errno;
@@ -862,10 +862,10 @@ unix_connect(char *path)
862 int s, save_errno; 862 int s, save_errno;
863 863
864 if (uflag) { 864 if (uflag) {
865 if ((s = unix_bind(unix_dg_tmp_socket, SOCK_CLOEXEC)) < 0) 865 if ((s = unix_bind(unix_dg_tmp_socket, SOCK_CLOEXEC)) == -1)
866 return -1; 866 return -1;
867 } else { 867 } else {
868 if ((s = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)) < 0) 868 if ((s = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)) == -1)
869 return -1; 869 return -1;
870 } 870 }
871 871
@@ -878,7 +878,7 @@ unix_connect(char *path)
878 errno = ENAMETOOLONG; 878 errno = ENAMETOOLONG;
879 return -1; 879 return -1;
880 } 880 }
881 if (connect(s, (struct sockaddr *)&s_un, sizeof(s_un)) < 0) { 881 if (connect(s, (struct sockaddr *)&s_un, sizeof(s_un)) == -1) {
882 save_errno = errno; 882 save_errno = errno;
883 close(s); 883 close(s);
884 errno = save_errno; 884 errno = save_errno;
@@ -897,9 +897,9 @@ unix_listen(char *path)
897{ 897{
898 int s; 898 int s;
899 899
900 if ((s = unix_bind(path, 0)) < 0) 900 if ((s = unix_bind(path, 0)) == -1)
901 return -1; 901 return -1;
902 if (listen(s, 5) < 0) { 902 if (listen(s, 5) == -1) {
903 close(s); 903 close(s);
904 return -1; 904 return -1;
905 } 905 }
@@ -926,7 +926,7 @@ remote_connect(const char *host, const char *port, struct addrinfo hints)
926 926
927 for (res = res0; res; res = res->ai_next) { 927 for (res = res0; res; res = res->ai_next) {
928 if ((s = socket(res->ai_family, res->ai_socktype | 928 if ((s = socket(res->ai_family, res->ai_socktype |
929 SOCK_NONBLOCK, res->ai_protocol)) < 0) 929 SOCK_NONBLOCK, res->ai_protocol)) == -1)
930 continue; 930 continue;
931 931
932 /* Bind to a local port or source address if specified. */ 932 /* Bind to a local port or source address if specified. */
@@ -944,7 +944,7 @@ remote_connect(const char *host, const char *port, struct addrinfo hints)
944 errx(1, "getaddrinfo: %s", gai_strerror(error)); 944 errx(1, "getaddrinfo: %s", gai_strerror(error));
945 945
946 if (bind(s, (struct sockaddr *)ares->ai_addr, 946 if (bind(s, (struct sockaddr *)ares->ai_addr,
947 ares->ai_addrlen) < 0) 947 ares->ai_addrlen) == -1)
948 err(1, "bind failed"); 948 err(1, "bind failed");
949 freeaddrinfo(ares); 949 freeaddrinfo(ares);
950 } 950 }
@@ -1023,7 +1023,7 @@ local_listen(const char *host, const char *port, struct addrinfo hints)
1023 1023
1024 for (res = res0; res; res = res->ai_next) { 1024 for (res = res0; res; res = res->ai_next) {
1025 if ((s = socket(res->ai_family, res->ai_socktype, 1025 if ((s = socket(res->ai_family, res->ai_socktype,
1026 res->ai_protocol)) < 0) 1026 res->ai_protocol)) == -1)
1027 continue; 1027 continue;
1028 1028
1029 ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); 1029 ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x));
@@ -1043,7 +1043,7 @@ local_listen(const char *host, const char *port, struct addrinfo hints)
1043 } 1043 }
1044 1044
1045 if (!uflag && s != -1) { 1045 if (!uflag && s != -1) {
1046 if (listen(s, 1) < 0) 1046 if (listen(s, 1) == -1)
1047 err(1, "listen"); 1047 err(1, "listen");
1048 } 1048 }
1049 if (vflag && s != -1) { 1049 if (vflag && s != -1) {
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c
index 2297b5bf2b..47e21265af 100644
--- a/src/usr.bin/openssl/apps.c
+++ b/src/usr.bin/openssl/apps.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: apps.c,v 1.51 2019/02/09 15:49:21 inoguchi Exp $ */ 1/* $OpenBSD: apps.c,v 1.52 2019/06/28 13:35:02 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -1377,7 +1377,7 @@ rotate_serial(char *serialfile, char *new_suffix, char *old_suffix)
1377 goto err; 1377 goto err;
1378 } 1378 }
1379 1379
1380 if (rename(serialfile, opath) < 0 && 1380 if (rename(serialfile, opath) == -1 &&
1381 errno != ENOENT && errno != ENOTDIR) { 1381 errno != ENOENT && errno != ENOTDIR) {
1382 BIO_printf(bio_err, "unable to rename %s to %s\n", 1382 BIO_printf(bio_err, "unable to rename %s to %s\n",
1383 serialfile, opath); 1383 serialfile, opath);
@@ -1386,11 +1386,11 @@ rotate_serial(char *serialfile, char *new_suffix, char *old_suffix)
1386 } 1386 }
1387 1387
1388 1388
1389 if (rename(npath, serialfile) < 0) { 1389 if (rename(npath, serialfile) == -1) {
1390 BIO_printf(bio_err, "unable to rename %s to %s\n", 1390 BIO_printf(bio_err, "unable to rename %s to %s\n",
1391 npath, serialfile); 1391 npath, serialfile);
1392 perror("reason"); 1392 perror("reason");
1393 if (rename(opath, serialfile) < 0) { 1393 if (rename(opath, serialfile) == -1) {
1394 BIO_printf(bio_err, "unable to rename %s to %s\n", 1394 BIO_printf(bio_err, "unable to rename %s to %s\n",
1395 opath, serialfile); 1395 opath, serialfile);
1396 perror("reason"); 1396 perror("reason");
@@ -1599,18 +1599,18 @@ rotate_index(const char *dbfile, const char *new_suffix, const char *old_suffix)
1599 goto err; 1599 goto err;
1600 } 1600 }
1601 1601
1602 if (rename(dbfile, odbpath) < 0 && errno != ENOENT && errno != ENOTDIR) { 1602 if (rename(dbfile, odbpath) == -1 && errno != ENOENT && errno != ENOTDIR) {
1603 BIO_printf(bio_err, "unable to rename %s to %s\n", 1603 BIO_printf(bio_err, "unable to rename %s to %s\n",
1604 dbfile, odbpath); 1604 dbfile, odbpath);
1605 perror("reason"); 1605 perror("reason");
1606 goto err; 1606 goto err;
1607 } 1607 }
1608 1608
1609 if (rename(dbpath, dbfile) < 0) { 1609 if (rename(dbpath, dbfile) == -1) {
1610 BIO_printf(bio_err, "unable to rename %s to %s\n", 1610 BIO_printf(bio_err, "unable to rename %s to %s\n",
1611 dbpath, dbfile); 1611 dbpath, dbfile);
1612 perror("reason"); 1612 perror("reason");
1613 if (rename(odbpath, dbfile) < 0) { 1613 if (rename(odbpath, dbfile) == -1) {
1614 BIO_printf(bio_err, "unable to rename %s to %s\n", 1614 BIO_printf(bio_err, "unable to rename %s to %s\n",
1615 odbpath, dbfile); 1615 odbpath, dbfile);
1616 perror("reason"); 1616 perror("reason");
@@ -1618,16 +1618,16 @@ rotate_index(const char *dbfile, const char *new_suffix, const char *old_suffix)
1618 goto err; 1618 goto err;
1619 } 1619 }
1620 1620
1621 if (rename(attrpath, oattrpath) < 0 && errno != ENOENT && errno != ENOTDIR) { 1621 if (rename(attrpath, oattrpath) == -1 && errno != ENOENT && errno != ENOTDIR) {
1622 BIO_printf(bio_err, "unable to rename %s to %s\n", 1622 BIO_printf(bio_err, "unable to rename %s to %s\n",
1623 attrpath, oattrpath); 1623 attrpath, oattrpath);
1624 perror("reason"); 1624 perror("reason");
1625 if (rename(dbfile, dbpath) < 0) { 1625 if (rename(dbfile, dbpath) == -1) {
1626 BIO_printf(bio_err, "unable to rename %s to %s\n", 1626 BIO_printf(bio_err, "unable to rename %s to %s\n",
1627 dbfile, dbpath); 1627 dbfile, dbpath);
1628 perror("reason"); 1628 perror("reason");
1629 } 1629 }
1630 if (rename(odbpath, dbfile) < 0) { 1630 if (rename(odbpath, dbfile) == -1) {
1631 BIO_printf(bio_err, "unable to rename %s to %s\n", 1631 BIO_printf(bio_err, "unable to rename %s to %s\n",
1632 odbpath, dbfile); 1632 odbpath, dbfile);
1633 perror("reason"); 1633 perror("reason");
@@ -1635,21 +1635,21 @@ rotate_index(const char *dbfile, const char *new_suffix, const char *old_suffix)
1635 goto err; 1635 goto err;
1636 } 1636 }
1637 1637
1638 if (rename(nattrpath, attrpath) < 0) { 1638 if (rename(nattrpath, attrpath) == -1) {
1639 BIO_printf(bio_err, "unable to rename %s to %s\n", 1639 BIO_printf(bio_err, "unable to rename %s to %s\n",
1640 nattrpath, attrpath); 1640 nattrpath, attrpath);
1641 perror("reason"); 1641 perror("reason");
1642 if (rename(oattrpath, attrpath) < 0) { 1642 if (rename(oattrpath, attrpath) == -1) {
1643 BIO_printf(bio_err, "unable to rename %s to %s\n", 1643 BIO_printf(bio_err, "unable to rename %s to %s\n",
1644 oattrpath, attrpath); 1644 oattrpath, attrpath);
1645 perror("reason"); 1645 perror("reason");
1646 } 1646 }
1647 if (rename(dbfile, dbpath) < 0) { 1647 if (rename(dbfile, dbpath) == -1) {
1648 BIO_printf(bio_err, "unable to rename %s to %s\n", 1648 BIO_printf(bio_err, "unable to rename %s to %s\n",
1649 dbfile, dbpath); 1649 dbfile, dbpath);
1650 perror("reason"); 1650 perror("reason");
1651 } 1651 }
1652 if (rename(odbpath, dbfile) < 0) { 1652 if (rename(odbpath, dbfile) == -1) {
1653 BIO_printf(bio_err, "unable to rename %s to %s\n", 1653 BIO_printf(bio_err, "unable to rename %s to %s\n",
1654 odbpath, dbfile); 1654 odbpath, dbfile);
1655 perror("reason"); 1655 perror("reason");
diff --git a/src/usr.bin/openssl/s_client.c b/src/usr.bin/openssl/s_client.c
index e542f08481..23bf67e695 100644
--- a/src/usr.bin/openssl/s_client.c
+++ b/src/usr.bin/openssl/s_client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s_client.c,v 1.37 2018/11/14 06:24:21 tb Exp $ */ 1/* $OpenBSD: s_client.c,v 1.38 2019/06/28 13:35:02 deraadt Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -759,7 +759,7 @@ re_start:
759 if (SSL_version(con) == DTLS1_VERSION) { 759 if (SSL_version(con) == DTLS1_VERSION) {
760 760
761 sbio = BIO_new_dgram(s, BIO_NOCLOSE); 761 sbio = BIO_new_dgram(s, BIO_NOCLOSE);
762 if (getsockname(s, &peer, (void *) &peerlen) < 0) { 762 if (getsockname(s, &peer, (void *) &peerlen) == -1) {
763 BIO_printf(bio_err, "getsockname:errno=%d\n", 763 BIO_printf(bio_err, "getsockname:errno=%d\n",
764 errno); 764 errno);
765 shutdown(s, SHUT_RD); 765 shutdown(s, SHUT_RD);
@@ -1013,7 +1013,7 @@ re_start:
1013 tty_on,read_tty,write_tty,read_ssl,write_ssl);*/ 1013 tty_on,read_tty,write_tty,read_ssl,write_ssl);*/
1014 1014
1015 i = poll(pfd, 3, ptimeout); 1015 i = poll(pfd, 3, ptimeout);
1016 if (i < 0) { 1016 if (i == -1) {
1017 BIO_printf(bio_err, "bad select %d\n", 1017 BIO_printf(bio_err, "bad select %d\n",
1018 errno); 1018 errno);
1019 goto shut; 1019 goto shut;
diff --git a/src/usr.bin/openssl/s_server.c b/src/usr.bin/openssl/s_server.c
index 4bdafaf682..a15795151f 100644
--- a/src/usr.bin/openssl/s_server.c
+++ b/src/usr.bin/openssl/s_server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s_server.c,v 1.30 2018/02/07 05:47:55 jsing Exp $ */ 1/* $OpenBSD: s_server.c,v 1.31 2019/06/28 13:35:02 deraadt Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -1512,7 +1512,7 @@ sv_body(char *hostname, int s, unsigned char *context)
1512 n = write(fileno(stdout), buf + len, i - len); 1512 n = write(fileno(stdout), buf + len, i - len);
1513 } while (n == -1 && errno == EINTR); 1513 } while (n == -1 && errno == EINTR);
1514 1514
1515 if (n < 0) { 1515 if (n == -1) {
1516 BIO_printf(bio_s_out, "ERROR\n"); 1516 BIO_printf(bio_s_out, "ERROR\n");
1517 goto err; 1517 goto err;
1518 } 1518 }
diff --git a/src/usr.bin/openssl/s_socket.c b/src/usr.bin/openssl/s_socket.c
index 62b32d3936..5d90fad8bb 100644
--- a/src/usr.bin/openssl/s_socket.c
+++ b/src/usr.bin/openssl/s_socket.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s_socket.c,v 1.10 2018/08/19 20:07:06 tb Exp $ */ 1/* $OpenBSD: s_socket.c,v 1.11 2019/06/28 13:35:02 deraadt Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -107,7 +107,7 @@ init_client(int *sock, char *host, char *port, int type, int af)
107 i = 0; 107 i = 0;
108 i = setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, 108 i = setsockopt(s, SOL_SOCKET, SO_KEEPALIVE,
109 (char *) &i, sizeof(i)); 109 (char *) &i, sizeof(i));
110 if (i < 0) { 110 if (i == -1) {
111 perror("keepalive"); 111 perror("keepalive");
112 goto out; 112 goto out;
113 } 113 }
@@ -251,10 +251,10 @@ do_accept(int acc_sock, int *sock, char **host)
251 ling.l_onoff=1; 251 ling.l_onoff=1;
252 ling.l_linger=0; 252 ling.l_linger=0;
253 i=setsockopt(ret,SOL_SOCKET,SO_LINGER,(char *)&ling,sizeof(ling)); 253 i=setsockopt(ret,SOL_SOCKET,SO_LINGER,(char *)&ling,sizeof(ling));
254 if (i < 0) { perror("linger"); return(0); } 254 if (i == -1) { perror("linger"); return(0); }
255 i=0; 255 i=0;
256 i=setsockopt(ret,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i)); 256 i=setsockopt(ret,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
257 if (i < 0) { perror("keepalive"); return(0); } 257 if (i == -1) { perror("keepalive"); return(0); }
258*/ 258*/
259 259
260 if (host == NULL) 260 if (host == NULL)
diff --git a/src/usr.sbin/ocspcheck/http.c b/src/usr.sbin/ocspcheck/http.c
index 5c914a4857..e0df6cfa11 100644
--- a/src/usr.sbin/ocspcheck/http.c
+++ b/src/usr.sbin/ocspcheck/http.c
@@ -1,4 +1,4 @@
1/* $Id: http.c,v 1.11 2018/11/29 14:25:07 tedu Exp $ */ 1/* $Id: http.c,v 1.12 2019/06/28 13:32:49 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv> 3 * Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
4 * 4 *
@@ -72,7 +72,7 @@ dosysread(char *buf, size_t sz, const struct http *http)
72 ssize_t rc; 72 ssize_t rc;
73 73
74 rc = read(http->fd, buf, sz); 74 rc = read(http->fd, buf, sz);
75 if (rc < 0) 75 if (rc == -1)
76 warn("%s: read", http->src.ip); 76 warn("%s: read", http->src.ip);
77 return rc; 77 return rc;
78} 78}
@@ -83,7 +83,7 @@ dosyswrite(const void *buf, size_t sz, const struct http *http)
83 ssize_t rc; 83 ssize_t rc;
84 84
85 rc = write(http->fd, buf, sz); 85 rc = write(http->fd, buf, sz);
86 if (rc < 0) 86 if (rc == -1)
87 warn("%s: write", http->src.ip); 87 warn("%s: write", http->src.ip);
88 return rc; 88 return rc;
89} 89}
@@ -97,7 +97,7 @@ dotlsread(char *buf, size_t sz, const struct http *http)
97 rc = tls_read(http->ctx, buf, sz); 97 rc = tls_read(http->ctx, buf, sz);
98 } while (rc == TLS_WANT_POLLIN || rc == TLS_WANT_POLLOUT); 98 } while (rc == TLS_WANT_POLLIN || rc == TLS_WANT_POLLOUT);
99 99
100 if (rc < 0) 100 if (rc == -1)
101 warnx("%s: tls_read: %s", http->src.ip, 101 warnx("%s: tls_read: %s", http->src.ip,
102 tls_error(http->ctx)); 102 tls_error(http->ctx));
103 return rc; 103 return rc;
@@ -112,7 +112,7 @@ dotlswrite(const void *buf, size_t sz, const struct http *http)
112 rc = tls_write(http->ctx, buf, sz); 112 rc = tls_write(http->ctx, buf, sz);
113 } while (rc == TLS_WANT_POLLIN || rc == TLS_WANT_POLLOUT); 113 } while (rc == TLS_WANT_POLLIN || rc == TLS_WANT_POLLOUT);
114 114
115 if (rc < 0) 115 if (rc == -1)
116 warnx("%s: tls_write: %s", http->src.ip, 116 warnx("%s: tls_write: %s", http->src.ip,
117 tls_error(http->ctx)); 117 tls_error(http->ctx));
118 return rc; 118 return rc;