summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2021-10-24 21:24:23 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2021-10-24 21:24:23 +0000
commitacc343614063e6fcbfd2871022b325f7f58f01cf (patch)
tree116317e06df569f5951d37b46db5c27b2326b826 /regress
parent45b1bea4b11d2420bea5874f47944b05075dd1b0 (diff)
For open/openat, if the flags parameter does not contain O_CREAT, the
3rd (variadic) mode_t parameter is irrelevant. Many developers in the past have passed mode_t (0, 044, 0644, or such), which might lead future people to copy this broken idiom, and perhaps even believe this parameter has some meaning or implication or application. Delete them all. This comes out of a conversation where tb@ noticed that a strange (but intentional) pledge behaviour is to always knock-out high-bits from mode_t on a number of system calls as a safety factor, and his bewilderment that this appeared to be happening against valid modes (at least visually), but no sorry, they are all irrelevant junk. They could all be 0xdeafbeef. ok millert
Diffstat (limited to 'regress')
-rw-r--r--regress/lib/libc/db/dbtest.c4
-rw-r--r--regress/lib/libc/sys/t_truncate.c4
-rw-r--r--regress/lib/libsndio/fd/fd.c2
-rw-r--r--regress/sys/dev/video/videotest.c6
-rw-r--r--regress/sys/kern/pledge/generic/main.c6
-rw-r--r--regress/sys/kern/ptmget/ptmget.c4
-rw-r--r--regress/sys/kern/unfdpass/unfdpass.c4
-rw-r--r--regress/sys/uvm/mmap0/mmap0.c4
-rw-r--r--regress/sys/uvm/mmap_4g/mmap_4g.c6
-rw-r--r--regress/usr.sbin/syslogd/logflush.c4
10 files changed, 22 insertions, 22 deletions
diff --git a/regress/lib/libc/db/dbtest.c b/regress/lib/libc/db/dbtest.c
index 57bb900f7a6..b520d8db72d 100644
--- a/regress/lib/libc/db/dbtest.c
+++ b/regress/lib/libc/db/dbtest.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dbtest.c,v 1.17 2020/02/14 19:17:33 schwarze Exp $ */
+/* $OpenBSD: dbtest.c,v 1.18 2021/10/24 21:24:20 deraadt Exp $ */
/* $NetBSD: dbtest.c,v 1.8 1996/05/03 21:57:48 cgd Exp $ */
/*-
@@ -680,7 +680,7 @@ rfile(name, lenp)
for (; isspace((unsigned char)*name); ++name);
if ((np = strchr(name, '\n')) != NULL)
*np = '\0';
- if ((fd = open(name, O_RDONLY, 0)) < 0 ||
+ if ((fd = open(name, O_RDONLY)) < 0 ||
fstat(fd, &sb))
dberr("%s: %s\n", name, strerror(errno));
if (sb.st_size > (off_t)INT_MAX)
diff --git a/regress/lib/libc/sys/t_truncate.c b/regress/lib/libc/sys/t_truncate.c
index 7f7987e32ec..7d3dedb7b88 100644
--- a/regress/lib/libc/sys/t_truncate.c
+++ b/regress/lib/libc/sys/t_truncate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: t_truncate.c,v 1.1 2019/11/19 19:57:04 bluhm Exp $ */
+/* $OpenBSD: t_truncate.c,v 1.2 2021/10/24 21:24:20 deraadt Exp $ */
/* $NetBSD: t_truncate.c,v 1.3 2017/01/13 20:03:51 christos Exp $ */
/*-
@@ -96,7 +96,7 @@ ATF_TC_BODY(ftruncate_err, tc)
{
int fd;
- fd = open("/etc/passwd", O_RDONLY, 0400);
+ fd = open("/etc/passwd", O_RDONLY);
ATF_REQUIRE(fd >= 0);
errno = 0;
diff --git a/regress/lib/libsndio/fd/fd.c b/regress/lib/libsndio/fd/fd.c
index e7b3b6420a2..af17facca09 100644
--- a/regress/lib/libsndio/fd/fd.c
+++ b/regress/lib/libsndio/fd/fd.c
@@ -306,7 +306,7 @@ main(int argc, char **argv)
events |= POLLIN;
}
if (playpath) {
- playfd = open(playpath, O_RDONLY, 0);
+ playfd = open(playpath, O_RDONLY);
if (playfd < 0) {
perror(playpath);
exit(1);
diff --git a/regress/sys/dev/video/videotest.c b/regress/sys/dev/video/videotest.c
index d2073ebebc7..fee7e02ac4f 100644
--- a/regress/sys/dev/video/videotest.c
+++ b/regress/sys/dev/video/videotest.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: videotest.c,v 1.5 2015/11/17 07:13:55 mmcc Exp $ */
+/* $OpenBSD: videotest.c,v 1.6 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Copyright (c) 2010 Marcus Glocker <mglocker@openbsd.org>
@@ -117,7 +117,7 @@ main(void)
DEV_PATH, dev_name);
/* open video device */
- fd = open(dev_full, O_RDWR, 0);
+ fd = open(dev_full, O_RDWR);
if (fd == -1) {
warn("%s", dev_full);
break;
@@ -317,7 +317,7 @@ test_capture(char *dev_name, char *dev_full, int access, int use_poll)
}
/* open device */
- fd1 = open(dev_full, O_RDWR, 0);
+ fd1 = open(dev_full, O_RDWR);
if (fd1 == -1)
err(1, "open");
sleep(WAIT_INIT); /* let device initialize */
diff --git a/regress/sys/kern/pledge/generic/main.c b/regress/sys/kern/pledge/generic/main.c
index fbea0e0cd7d..3f950d32e23 100644
--- a/regress/sys/kern/pledge/generic/main.c
+++ b/regress/sys/kern/pledge/generic/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.10 2017/12/15 14:45:51 bluhm Exp $ */
+/* $OpenBSD: main.c,v 1.11 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Copyright (c) 2015 Sebastien Marie <semarie@openbsd.org>
*
@@ -74,7 +74,7 @@ test_rpath()
int fd;
char data[512];
- if ((fd = open("/dev/zero", O_RDONLY, 0)) == -1)
+ if ((fd = open("/dev/zero", O_RDONLY)) == -1)
_exit(errno);
if (read(fd, data, sizeof(data)) == -1)
@@ -89,7 +89,7 @@ test_wpath()
int fd;
char data[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
- if ((fd = open("/dev/null", O_WRONLY, 0)) == -1)
+ if ((fd = open("/dev/null", O_WRONLY)) == -1)
_exit(errno);
if (write(fd, data, sizeof(data)) == -1)
diff --git a/regress/sys/kern/ptmget/ptmget.c b/regress/sys/kern/ptmget/ptmget.c
index 5c1b0713bd1..0d419bbfc93 100644
--- a/regress/sys/kern/ptmget/ptmget.c
+++ b/regress/sys/kern/ptmget/ptmget.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ptmget.c,v 1.3 2016/08/27 04:34:28 guenther Exp $ */
+/* $OpenBSD: ptmget.c,v 1.4 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Written by Bob Beck <beck@openbsd.org> 2004 Public Domain.
* Basic test to ensure /dev/ptm works, and what it returns
@@ -31,7 +31,7 @@ main(int argc, char *argv[])
ttygid = gr->gr_gid;
else
ttygid = 4;
- fd = open("/dev/ptm", O_RDWR, 0);
+ fd = open("/dev/ptm", O_RDWR);
if (fd == -1)
err(1, "Can't open /dev/ptm");
if ((ioctl(fd, PTMGET, &ptm) == -1))
diff --git a/regress/sys/kern/unfdpass/unfdpass.c b/regress/sys/kern/unfdpass/unfdpass.c
index 65c1a4e9a38..264c73ec1e5 100644
--- a/regress/sys/kern/unfdpass/unfdpass.c
+++ b/regress/sys/kern/unfdpass/unfdpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: unfdpass.c,v 1.20 2018/11/28 08:06:22 claudio Exp $ */
+/* $OpenBSD: unfdpass.c,v 1.21 2021/10/24 21:24:20 deraadt Exp $ */
/* $NetBSD: unfdpass.c,v 1.3 1998/06/24 23:51:30 thorpej Exp $ */
/*-
@@ -303,7 +303,7 @@ child(int sock, int type, int oflag)
files = (int *)CMSG_DATA(cmp);
for (i = 0; i < nfds; i++) {
(void) snprintf(fname, sizeof fname, "file%d", i + 1);
- if ((fd = open(fname, O_RDONLY, 0666)) == -1)
+ if ((fd = open(fname, O_RDONLY)) == -1)
err(1, "child open %s", fname);
files[i] = fd;
}
diff --git a/regress/sys/uvm/mmap0/mmap0.c b/regress/sys/uvm/mmap0/mmap0.c
index d750fa5e295..dd9319bf362 100644
--- a/regress/sys/uvm/mmap0/mmap0.c
+++ b/regress/sys/uvm/mmap0/mmap0.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mmap0.c,v 1.2 2016/08/27 04:35:19 guenther Exp $ */
+/* $OpenBSD: mmap0.c,v 1.3 2021/10/24 21:24:20 deraadt Exp $ */
/*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
*
@@ -37,7 +37,7 @@ main()
int errors = 0;
int fd;
- fd = open("/dev/zero", O_RDWR, 0);
+ fd = open("/dev/zero", O_RDWR);
if (fd == -1)
err(EX_OSERR, "open");
diff --git a/regress/sys/uvm/mmap_4g/mmap_4g.c b/regress/sys/uvm/mmap_4g/mmap_4g.c
index c2fb95ebe61..201d7308514 100644
--- a/regress/sys/uvm/mmap_4g/mmap_4g.c
+++ b/regress/sys/uvm/mmap_4g/mmap_4g.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mmap_4g.c,v 1.4 2019/09/20 12:52:30 bluhm Exp $ */
+/* $OpenBSD: mmap_4g.c,v 1.5 2021/10/24 21:24:21 deraadt Exp $ */
/*
* Public domain. 2005, Otto Moerbeek <otto@drijf.net>
@@ -40,7 +40,7 @@ main()
err(1, "write");
close(fd);
- fd = open(file, O_RDWR, 0);
+ fd = open(file, O_RDWR);
if (fd == -1)
err(1, "open");
p = mmap(NULL, 100, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED,
@@ -53,7 +53,7 @@ main()
err(1, "munmap");
close(fd);
- fd = open(file, O_RDONLY, 0);
+ fd = open(file, O_RDONLY);
if (fd == -1)
err(1, "open");
if (read(fd, buf, sz) != sz)
diff --git a/regress/usr.sbin/syslogd/logflush.c b/regress/usr.sbin/syslogd/logflush.c
index e4772eb171d..6cb24bcda4d 100644
--- a/regress/usr.sbin/syslogd/logflush.c
+++ b/regress/usr.sbin/syslogd/logflush.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: logflush.c,v 1.1 2021/03/09 15:16:28 bluhm Exp $ */
+/* $OpenBSD: logflush.c,v 1.2 2021/10/24 21:24:21 deraadt Exp $ */
/*
* Copyright (c) 2021 Alexander Bluhm <bluhm@openbsd.org>
@@ -52,7 +52,7 @@ main(int argc, char *argv[])
if (setsockopt(pair[1], SOL_SOCKET, SO_SNDBUF, &val, sizeof(val)) == -1)
err(1, "setsockopt SO_SNDBUF");
- if ((klog = open(_PATH_KLOG, O_RDONLY, 0)) == -1)
+ if ((klog = open(_PATH_KLOG, O_RDONLY)) == -1)
err(1, "open %s", _PATH_KLOG);
/* Use /dev/klog to register sendsyslog(2) receiver. */
if (ioctl(klog, LIOCSFD, &pair[1]) == -1)