From 6585927e66d9ab172754d95c4296dd4309a40512 Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Fri, 28 Jun 2019 13:35:02 +0000 Subject: 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. --- src/usr.sbin/ocspcheck/http.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/usr.sbin/ocspcheck') 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 @@ -/* $Id: http.c,v 1.11 2018/11/29 14:25:07 tedu Exp $ */ +/* $Id: http.c,v 1.12 2019/06/28 13:32:49 deraadt Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons * @@ -72,7 +72,7 @@ dosysread(char *buf, size_t sz, const struct http *http) ssize_t rc; rc = read(http->fd, buf, sz); - if (rc < 0) + if (rc == -1) warn("%s: read", http->src.ip); return rc; } @@ -83,7 +83,7 @@ dosyswrite(const void *buf, size_t sz, const struct http *http) ssize_t rc; rc = write(http->fd, buf, sz); - if (rc < 0) + if (rc == -1) warn("%s: write", http->src.ip); return rc; } @@ -97,7 +97,7 @@ dotlsread(char *buf, size_t sz, const struct http *http) rc = tls_read(http->ctx, buf, sz); } while (rc == TLS_WANT_POLLIN || rc == TLS_WANT_POLLOUT); - if (rc < 0) + if (rc == -1) warnx("%s: tls_read: %s", http->src.ip, tls_error(http->ctx)); return rc; @@ -112,7 +112,7 @@ dotlswrite(const void *buf, size_t sz, const struct http *http) rc = tls_write(http->ctx, buf, sz); } while (rc == TLS_WANT_POLLIN || rc == TLS_WANT_POLLOUT); - if (rc < 0) + if (rc == -1) warnx("%s: tls_write: %s", http->src.ip, tls_error(http->ctx)); return rc; -- cgit v1.2.3-55-g6feb