summaryrefslogtreecommitdiffstats
path: root/usr.bin/look
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2019-06-28 13:34:58 +0000
committerderaadt <deraadt@openbsd.org>2019-06-28 13:34:58 +0000
commit3aaa63eb46949490a39db9c6d82aacc8ee5d8551 (patch)
treeef48ea58ad350ab9d01fbfe32455a1df1fa2340c /usr.bin/look
parentfputc/fputs return EOF on error (diff)
downloadwireguard-openbsd-3aaa63eb46949490a39db9c6d82aacc8ee5d8551.tar.xz
wireguard-openbsd-3aaa63eb46949490a39db9c6d82aacc8ee5d8551.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 'usr.bin/look')
-rw-r--r--usr.bin/look/look.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/look/look.c b/usr.bin/look/look.c
index baf3486d852..fa0b7353bc2 100644
--- a/usr.bin/look/look.c
+++ b/usr.bin/look/look.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: look.c,v 1.22 2018/08/11 11:00:34 mestre Exp $ */
+/* $OpenBSD: look.c,v 1.23 2019/06/28 13:35:01 deraadt Exp $ */
/* $NetBSD: look.c,v 1.7 1995/08/31 22:41:02 jtc Exp $ */
/*-
@@ -118,7 +118,7 @@ main(int argc, char *argv[])
if (termchar != '\0' && (p = strchr(string, termchar)) != NULL)
*++p = '\0';
- if ((fd = open(file, O_RDONLY, 0)) < 0 || fstat(fd, &sb))
+ if ((fd = open(file, O_RDONLY, 0)) == -1 || fstat(fd, &sb) == -1)
err(2, "%s", file);
if (sb.st_size > SIZE_MAX)
errc(2, EFBIG, "%s", file);