From cc848da117f06eb2ae32eaca4e146eb981a14d83 Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Sun, 24 Oct 2021 21:24:20 +0000 Subject: 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 --- src/lib/libc/stdlib/getopt.3 | 6 +++--- src/lib/libc/stdlib/getopt_long.3 | 6 +++--- src/lib/libcrypto/arc4random/getentropy_aix.c | 4 ++-- src/lib/libcrypto/arc4random/getentropy_hpux.c | 4 ++-- src/lib/libcrypto/arc4random/getentropy_linux.c | 4 ++-- src/lib/libcrypto/arc4random/getentropy_osx.c | 4 ++-- src/lib/libcrypto/arc4random/getentropy_solaris.c | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/lib') 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 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: getopt.3,v 1.46 2016/01/04 19:43:13 tb Exp $ +.\" $OpenBSD: getopt.3,v 1.47 2021/10/24 21:24:20 deraadt Exp $ .\" -.Dd $Mdocdate: January 4 2016 $ +.Dd $Mdocdate: October 24 2021 $ .Dt GETOPT 3 .Os .Sh NAME @@ -178,7 +178,7 @@ while ((ch = getopt(argc, argv, "bf:")) != -1) { bflag = 1; break; case 'f': - if ((fd = open(optarg, O_RDONLY, 0)) == -1) + if ((fd = open(optarg, O_RDONLY)) == -1) err(1, "%s", optarg); break; 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 @@ -.\" $OpenBSD: getopt_long.3,v 1.22 2020/01/13 18:05:10 stsp Exp $ +.\" $OpenBSD: getopt_long.3,v 1.23 2021/10/24 21:24:20 deraadt Exp $ .\" $NetBSD: getopt_long.3,v 1.11 2002/10/02 10:54:19 wiz Exp $ .\" .\" Copyright (c) 1988, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)getopt.3 8.5 (Berkeley) 4/27/95 .\" -.Dd $Mdocdate: January 13 2020 $ +.Dd $Mdocdate: October 24 2021 $ .Dt GETOPT_LONG 3 .Os .Sh NAME @@ -426,7 +426,7 @@ while ((ch = getopt_long(argc, argv, "bf:", longopts, NULL)) != -1) bflag = 1; break; case 'f': - if ((fd = open(optarg, O_RDONLY, 0)) == -1) + if ((fd = open(optarg, O_RDONLY)) == -1) err(1, "unable to open %s", optarg); break; 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 @@ -/* $OpenBSD: getentropy_aix.c,v 1.7 2020/05/17 14:44:20 deraadt Exp $ */ +/* $OpenBSD: getentropy_aix.c,v 1.8 2021/10/24 21:24:20 deraadt Exp $ */ /* * Copyright (c) 2015 Michael Felt @@ -134,7 +134,7 @@ start: #ifdef O_CLOEXEC flags |= O_CLOEXEC; #endif - fd = open(path, flags, 0); + fd = open(path, flags); if (fd == -1) { if (errno == EINTR) 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 @@ -/* $OpenBSD: getentropy_hpux.c,v 1.7 2020/05/17 14:44:20 deraadt Exp $ */ +/* $OpenBSD: getentropy_hpux.c,v 1.8 2021/10/24 21:24:20 deraadt Exp $ */ /* * Copyright (c) 2014 Theo de Raadt @@ -138,7 +138,7 @@ start: #ifdef O_CLOEXEC flags |= O_CLOEXEC; #endif - fd = open(path, flags, 0); + fd = open(path, flags); if (fd == -1) { if (errno == EINTR) 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 @@ -/* $OpenBSD: getentropy_linux.c,v 1.47 2020/05/17 14:44:20 deraadt Exp $ */ +/* $OpenBSD: getentropy_linux.c,v 1.48 2021/10/24 21:24:20 deraadt Exp $ */ /* * Copyright (c) 2014 Theo de Raadt @@ -212,7 +212,7 @@ start: #ifdef O_CLOEXEC flags |= O_CLOEXEC; #endif - fd = open("/dev/urandom", flags, 0); + fd = open("/dev/urandom", flags); if (fd == -1) { if (errno == EINTR) 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 @@ -/* $OpenBSD: getentropy_osx.c,v 1.13 2020/05/17 14:44:20 deraadt Exp $ */ +/* $OpenBSD: getentropy_osx.c,v 1.14 2021/10/24 21:24:20 deraadt Exp $ */ /* * Copyright (c) 2014 Theo de Raadt @@ -158,7 +158,7 @@ start: #ifdef O_CLOEXEC flags |= O_CLOEXEC; #endif - fd = open("/dev/urandom", flags, 0); + fd = open("/dev/urandom", flags); if (fd == -1) { if (errno == EINTR) 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 @@ -/* $OpenBSD: getentropy_solaris.c,v 1.14 2020/05/17 14:44:20 deraadt Exp $ */ +/* $OpenBSD: getentropy_solaris.c,v 1.15 2021/10/24 21:24:20 deraadt Exp $ */ /* * Copyright (c) 2014 Theo de Raadt @@ -164,7 +164,7 @@ start: #ifdef O_CLOEXEC flags |= O_CLOEXEC; #endif - fd = open(path, flags, 0); + fd = open(path, flags); if (fd == -1) { if (errno == EINTR) goto start; -- cgit v1.2.3-55-g6feb