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 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/lib/libc/stdlib/getopt.3') 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: -- cgit v1.2.3-55-g6feb