summaryrefslogtreecommitdiff
path: root/src/usr.sbin/ocspcheck
diff options
context:
space:
mode:
authorderaadt <>2019-06-28 13:35:02 +0000
committerderaadt <>2019-06-28 13:35:02 +0000
commit6585927e66d9ab172754d95c4296dd4309a40512 (patch)
treebc969c069c7b769f2601db17f08bec99274202a5 /src/usr.sbin/ocspcheck
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.
Diffstat (limited to 'src/usr.sbin/ocspcheck')
-rw-r--r--src/usr.sbin/ocspcheck/http.c10
1 files changed, 5 insertions, 5 deletions
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;