upstream: 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

OpenBSD-Commit-ID: 503d11633497115688c0c6952686524f01f53121
This commit is contained in:
deraadt@openbsd.org 2021-10-24 21:24:17 +00:00 committed by Damien Miller
parent d575cf4489
commit d4bed54456
2 changed files with 4 additions and 4 deletions

4
scp.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: scp.c,v 1.240 2021/10/15 14:46:46 deraadt Exp $ */ /* $OpenBSD: scp.c,v 1.241 2021/10/24 21:24:17 deraadt Exp $ */
/* /*
* scp - secure remote copy. This is basically patched BSD rcp which * scp - secure remote copy. This is basically patched BSD rcp which
* uses ssh to do the data transfer (instead of using rcmd). * uses ssh to do the data transfer (instead of using rcmd).
@ -1327,7 +1327,7 @@ source(int argc, char **argv)
len = strlen(name); len = strlen(name);
while (len > 1 && name[len-1] == '/') while (len > 1 && name[len-1] == '/')
name[--len] = '\0'; name[--len] = '\0';
if ((fd = open(name, O_RDONLY|O_NONBLOCK, 0)) == -1) if ((fd = open(name, O_RDONLY|O_NONBLOCK)) == -1)
goto syserr; goto syserr;
if (strchr(name, '\n') != NULL) { if (strchr(name, '\n') != NULL) {
strnvis(encname, name, sizeof(encname), VIS_NL); strnvis(encname, name, sizeof(encname), VIS_NL);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sftp-client.c,v 1.155 2021/09/03 05:12:25 dtucker Exp $ */ /* $OpenBSD: sftp-client.c,v 1.156 2021/10/24 21:24:17 deraadt Exp $ */
/* /*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
* *
@ -1840,7 +1840,7 @@ do_upload(struct sftp_conn *conn, const char *local_path,
TAILQ_INIT(&acks); TAILQ_INIT(&acks);
if ((local_fd = open(local_path, O_RDONLY, 0)) == -1) { if ((local_fd = open(local_path, O_RDONLY)) == -1) {
error("Couldn't open local file \"%s\" for reading: %s", error("Couldn't open local file \"%s\" for reading: %s",
local_path, strerror(errno)); local_path, strerror(errno));
return(-1); return(-1);