summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorderaadt <>2021-10-24 21:24:20 +0000
committerderaadt <>2021-10-24 21:24:20 +0000
commitcc848da117f06eb2ae32eaca4e146eb981a14d83 (patch)
treeff84c733b0f95e616f61320c664f8d9ca970aa16 /src
parent86484520bb9fdf67e7e47b29f0fed6ff22b63378 (diff)
downloadopenbsd-cc848da117f06eb2ae32eaca4e146eb981a14d83.tar.gz
openbsd-cc848da117f06eb2ae32eaca4e146eb981a14d83.tar.bz2
openbsd-cc848da117f06eb2ae32eaca4e146eb981a14d83.zip
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 'src')
-rw-r--r--src/lib/libc/stdlib/getopt.36
-rw-r--r--src/lib/libc/stdlib/getopt_long.36
-rw-r--r--src/lib/libcrypto/arc4random/getentropy_aix.c4
-rw-r--r--src/lib/libcrypto/arc4random/getentropy_hpux.c4
-rw-r--r--src/lib/libcrypto/arc4random/getentropy_linux.c4
-rw-r--r--src/lib/libcrypto/arc4random/getentropy_osx.c4
-rw-r--r--src/lib/libcrypto/arc4random/getentropy_solaris.c4
-rw-r--r--src/regress/lib/libc/db/dbtest.c4
-rw-r--r--src/regress/lib/libc/sys/t_truncate.c4
9 files changed, 20 insertions, 20 deletions
diff --git a/src/lib/libc/stdlib/getopt.3 b/src/lib/libc/stdlib/getopt.3
index af43ca6660..4a1d727388 100644
--- a/src/lib/libc/stdlib/getopt.3
+++ b/src/lib/libc/stdlib/getopt.3
@@ -25,9 +25,9 @@
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE. 26.\" SUCH DAMAGE.
27.\" 27.\"
28.\" $OpenBSD: getopt.3,v 1.46 2016/01/04 19:43:13 tb Exp $ 28.\" $OpenBSD: getopt.3,v 1.47 2021/10/24 21:24:20 deraadt Exp $
29.\" 29.\"
30.Dd $Mdocdate: January 4 2016 $ 30.Dd $Mdocdate: October 24 2021 $
31.Dt GETOPT 3 31.Dt GETOPT 3
32.Os 32.Os
33.Sh NAME 33.Sh NAME
@@ -178,7 +178,7 @@ while ((ch = getopt(argc, argv, "bf:")) != -1) {
178 bflag = 1; 178 bflag = 1;
179 break; 179 break;
180 case 'f': 180 case 'f':
181 if ((fd = open(optarg, O_RDONLY, 0)) == -1) 181 if ((fd = open(optarg, O_RDONLY)) == -1)
182 err(1, "%s", optarg); 182 err(1, "%s", optarg);
183 break; 183 break;
184 default: 184 default:
diff --git a/src/lib/libc/stdlib/getopt_long.3 b/src/lib/libc/stdlib/getopt_long.3
index 706619203f..a1fb404674 100644
--- a/src/lib/libc/stdlib/getopt_long.3
+++ b/src/lib/libc/stdlib/getopt_long.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: getopt_long.3,v 1.22 2020/01/13 18:05:10 stsp Exp $ 1.\" $OpenBSD: getopt_long.3,v 1.23 2021/10/24 21:24:20 deraadt Exp $
2.\" $NetBSD: getopt_long.3,v 1.11 2002/10/02 10:54:19 wiz Exp $ 2.\" $NetBSD: getopt_long.3,v 1.11 2002/10/02 10:54:19 wiz Exp $
3.\" 3.\"
4.\" Copyright (c) 1988, 1991, 1993 4.\" Copyright (c) 1988, 1991, 1993
@@ -30,7 +30,7 @@
30.\" 30.\"
31.\" @(#)getopt.3 8.5 (Berkeley) 4/27/95 31.\" @(#)getopt.3 8.5 (Berkeley) 4/27/95
32.\" 32.\"
33.Dd $Mdocdate: January 13 2020 $ 33.Dd $Mdocdate: October 24 2021 $
34.Dt GETOPT_LONG 3 34.Dt GETOPT_LONG 3
35.Os 35.Os
36.Sh NAME 36.Sh NAME
@@ -426,7 +426,7 @@ while ((ch = getopt_long(argc, argv, "bf:", longopts, NULL)) != -1)
426 bflag = 1; 426 bflag = 1;
427 break; 427 break;
428 case 'f': 428 case 'f':
429 if ((fd = open(optarg, O_RDONLY, 0)) == -1) 429 if ((fd = open(optarg, O_RDONLY)) == -1)
430 err(1, "unable to open %s", optarg); 430 err(1, "unable to open %s", optarg);
431 break; 431 break;
432 case 0: 432 case 0:
diff --git a/src/lib/libcrypto/arc4random/getentropy_aix.c b/src/lib/libcrypto/arc4random/getentropy_aix.c
index 422e685dd8..7fb857e6d2 100644
--- a/src/lib/libcrypto/arc4random/getentropy_aix.c
+++ b/src/lib/libcrypto/arc4random/getentropy_aix.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: getentropy_aix.c,v 1.7 2020/05/17 14:44:20 deraadt Exp $ */ 1/* $OpenBSD: getentropy_aix.c,v 1.8 2021/10/24 21:24:20 deraadt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2015 Michael Felt <aixtools@gmail.com> 4 * Copyright (c) 2015 Michael Felt <aixtools@gmail.com>
@@ -134,7 +134,7 @@ start:
134#ifdef O_CLOEXEC 134#ifdef O_CLOEXEC
135 flags |= O_CLOEXEC; 135 flags |= O_CLOEXEC;
136#endif 136#endif
137 fd = open(path, flags, 0); 137 fd = open(path, flags);
138 if (fd == -1) { 138 if (fd == -1) {
139 if (errno == EINTR) 139 if (errno == EINTR)
140 goto start; 140 goto start;
diff --git a/src/lib/libcrypto/arc4random/getentropy_hpux.c b/src/lib/libcrypto/arc4random/getentropy_hpux.c
index c981880aad..7188ae5e19 100644
--- a/src/lib/libcrypto/arc4random/getentropy_hpux.c
+++ b/src/lib/libcrypto/arc4random/getentropy_hpux.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: getentropy_hpux.c,v 1.7 2020/05/17 14:44:20 deraadt Exp $ */ 1/* $OpenBSD: getentropy_hpux.c,v 1.8 2021/10/24 21:24:20 deraadt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> 4 * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
@@ -138,7 +138,7 @@ start:
138#ifdef O_CLOEXEC 138#ifdef O_CLOEXEC
139 flags |= O_CLOEXEC; 139 flags |= O_CLOEXEC;
140#endif 140#endif
141 fd = open(path, flags, 0); 141 fd = open(path, flags);
142 if (fd == -1) { 142 if (fd == -1) {
143 if (errno == EINTR) 143 if (errno == EINTR)
144 goto start; 144 goto start;
diff --git a/src/lib/libcrypto/arc4random/getentropy_linux.c b/src/lib/libcrypto/arc4random/getentropy_linux.c
index bc7a6bef7b..c7c39c234f 100644
--- a/src/lib/libcrypto/arc4random/getentropy_linux.c
+++ b/src/lib/libcrypto/arc4random/getentropy_linux.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: getentropy_linux.c,v 1.47 2020/05/17 14:44:20 deraadt Exp $ */ 1/* $OpenBSD: getentropy_linux.c,v 1.48 2021/10/24 21:24:20 deraadt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> 4 * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
@@ -212,7 +212,7 @@ start:
212#ifdef O_CLOEXEC 212#ifdef O_CLOEXEC
213 flags |= O_CLOEXEC; 213 flags |= O_CLOEXEC;
214#endif 214#endif
215 fd = open("/dev/urandom", flags, 0); 215 fd = open("/dev/urandom", flags);
216 if (fd == -1) { 216 if (fd == -1) {
217 if (errno == EINTR) 217 if (errno == EINTR)
218 goto start; 218 goto start;
diff --git a/src/lib/libcrypto/arc4random/getentropy_osx.c b/src/lib/libcrypto/arc4random/getentropy_osx.c
index 5d4067bb8e..db028d19b8 100644
--- a/src/lib/libcrypto/arc4random/getentropy_osx.c
+++ b/src/lib/libcrypto/arc4random/getentropy_osx.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: getentropy_osx.c,v 1.13 2020/05/17 14:44:20 deraadt Exp $ */ 1/* $OpenBSD: getentropy_osx.c,v 1.14 2021/10/24 21:24:20 deraadt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> 4 * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
@@ -158,7 +158,7 @@ start:
158#ifdef O_CLOEXEC 158#ifdef O_CLOEXEC
159 flags |= O_CLOEXEC; 159 flags |= O_CLOEXEC;
160#endif 160#endif
161 fd = open("/dev/urandom", flags, 0); 161 fd = open("/dev/urandom", flags);
162 if (fd == -1) { 162 if (fd == -1) {
163 if (errno == EINTR) 163 if (errno == EINTR)
164 goto start; 164 goto start;
diff --git a/src/lib/libcrypto/arc4random/getentropy_solaris.c b/src/lib/libcrypto/arc4random/getentropy_solaris.c
index cf5b9bffa6..e36426caf1 100644
--- a/src/lib/libcrypto/arc4random/getentropy_solaris.c
+++ b/src/lib/libcrypto/arc4random/getentropy_solaris.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: getentropy_solaris.c,v 1.14 2020/05/17 14:44:20 deraadt Exp $ */ 1/* $OpenBSD: getentropy_solaris.c,v 1.15 2021/10/24 21:24:20 deraadt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> 4 * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
@@ -164,7 +164,7 @@ start:
164#ifdef O_CLOEXEC 164#ifdef O_CLOEXEC
165 flags |= O_CLOEXEC; 165 flags |= O_CLOEXEC;
166#endif 166#endif
167 fd = open(path, flags, 0); 167 fd = open(path, flags);
168 if (fd == -1) { 168 if (fd == -1) {
169 if (errno == EINTR) 169 if (errno == EINTR)
170 goto start; 170 goto start;
diff --git a/src/regress/lib/libc/db/dbtest.c b/src/regress/lib/libc/db/dbtest.c
index 57bb900f7a..b520d8db72 100644
--- a/src/regress/lib/libc/db/dbtest.c
+++ b/src/regress/lib/libc/db/dbtest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dbtest.c,v 1.17 2020/02/14 19:17:33 schwarze Exp $ */ 1/* $OpenBSD: dbtest.c,v 1.18 2021/10/24 21:24:20 deraadt Exp $ */
2/* $NetBSD: dbtest.c,v 1.8 1996/05/03 21:57:48 cgd Exp $ */ 2/* $NetBSD: dbtest.c,v 1.8 1996/05/03 21:57:48 cgd Exp $ */
3 3
4/*- 4/*-
@@ -680,7 +680,7 @@ rfile(name, lenp)
680 for (; isspace((unsigned char)*name); ++name); 680 for (; isspace((unsigned char)*name); ++name);
681 if ((np = strchr(name, '\n')) != NULL) 681 if ((np = strchr(name, '\n')) != NULL)
682 *np = '\0'; 682 *np = '\0';
683 if ((fd = open(name, O_RDONLY, 0)) < 0 || 683 if ((fd = open(name, O_RDONLY)) < 0 ||
684 fstat(fd, &sb)) 684 fstat(fd, &sb))
685 dberr("%s: %s\n", name, strerror(errno)); 685 dberr("%s: %s\n", name, strerror(errno));
686 if (sb.st_size > (off_t)INT_MAX) 686 if (sb.st_size > (off_t)INT_MAX)
diff --git a/src/regress/lib/libc/sys/t_truncate.c b/src/regress/lib/libc/sys/t_truncate.c
index 1d059af5f5..7d3dedb7b8 100644
--- a/src/regress/lib/libc/sys/t_truncate.c
+++ b/src/regress/lib/libc/sys/t_truncate.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t_truncate.c,v 1.1.1.1 2019/11/19 19:57:04 bluhm Exp $ */ 1/* $OpenBSD: t_truncate.c,v 1.2 2021/10/24 21:24:20 deraadt Exp $ */
2/* $NetBSD: t_truncate.c,v 1.3 2017/01/13 20:03:51 christos Exp $ */ 2/* $NetBSD: t_truncate.c,v 1.3 2017/01/13 20:03:51 christos Exp $ */
3 3
4/*- 4/*-
@@ -96,7 +96,7 @@ ATF_TC_BODY(ftruncate_err, tc)
96{ 96{
97 int fd; 97 int fd;
98 98
99 fd = open("/etc/passwd", O_RDONLY, 0400); 99 fd = open("/etc/passwd", O_RDONLY);
100 ATF_REQUIRE(fd >= 0); 100 ATF_REQUIRE(fd >= 0);
101 101
102 errno = 0; 102 errno = 0;