For open/openat, if the flags parameter does not contain O_CREAT, the
authorderaadt <deraadt@openbsd.org>
Sun, 24 Oct 2021 21:24:15 +0000 (21:24 +0000)
committerderaadt <deraadt@openbsd.org>
Sun, 24 Oct 2021 21:24:15 +0000 (21:24 +0000)
commitb7041c0781c8668129da8084451ded41b0c43954
tree2e3d9566d5147385233fb68e2032522656124d28
parent4f56c6f5d2fe98361a329682caa613b3232f93ee
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
133 files changed:
bin/cat/cat.c
bin/chio/chio.c
bin/cp/utils.c
bin/dd/dd.c
bin/ksh/exec.c
bin/ksh/tty.c
bin/mv/cp.c
bin/mv/mv.c
bin/pax/ar_subs.c
bin/rm/rm.c
lib/libc/gen/authenticate.c
lib/libc/gen/daemon.c
lib/libc/gen/err.3
lib/libc/stdlib/getopt.3
lib/libc/stdlib/getopt_long.3
lib/libcrypto/arc4random/getentropy_aix.c
lib/libcrypto/arc4random/getentropy_hpux.c
lib/libcrypto/arc4random/getentropy_linux.c
lib/libcrypto/arc4random/getentropy_osx.c
lib/libcrypto/arc4random/getentropy_solaris.c
lib/libcurses/tinfo/read_termcap.c
lib/libkeynote/keynote-sign.c
lib/libkeynote/keynote-sigver.c
lib/libkeynote/keynote-verify.c
lib/libutil/check_expire.c
libexec/ftpd/logwtmp.c
libexec/ftpd/monitor.c
libexec/ld.so/ldconfig/ldconfig.c
regress/lib/libc/db/dbtest.c
regress/lib/libc/sys/t_truncate.c
regress/lib/libsndio/fd/fd.c
regress/sys/dev/video/videotest.c
regress/sys/kern/pledge/generic/main.c
regress/sys/kern/ptmget/ptmget.c
regress/sys/kern/unfdpass/unfdpass.c
regress/sys/uvm/mmap0/mmap0.c
regress/sys/uvm/mmap_4g/mmap_4g.c
regress/usr.sbin/syslogd/logflush.c
sbin/dhclient/dhclient.c
sbin/init/init.c
sbin/isakmpd/monitor.c
sbin/isakmpd/ui.c
sbin/mount_udf/mount_udf.c
sbin/restore/symtab.c
sbin/savecore/savecore.c
sbin/ttyflags/ttyflags.c
sys/arch/alpha/stand/headersize.c
sys/arch/alpha/stand/setnetbootinfo/setnetbootinfo.c
usr.bin/aucat/afile.c
usr.bin/calendar/io.c
usr.bin/cdio/cdio.c
usr.bin/chpass/chpass.c
usr.bin/cmp/cmp.c
usr.bin/cvs/buf.c
usr.bin/cvs/diff.c
usr.bin/cvs/file.c
usr.bin/diff/diffreg.c
usr.bin/find/main.c
usr.bin/last/last.c
usr.bin/login/failedlogin.c
usr.bin/login/login.c
usr.bin/look/look.c
usr.bin/mail/lex.c
usr.bin/mandoc/cgi.c
usr.bin/mandoc/mandocdb.c
usr.bin/midicat/midicat.c
usr.bin/passwd/local_passwd.c
usr.bin/patch/util.c
usr.bin/rcs/buf.c
usr.bin/rdist/isexec.c
usr.bin/rsync/copy.c
usr.bin/rsync/downloader.c
usr.bin/rsync/receiver.c
usr.bin/rsync/uploader.c
usr.bin/sdiff/sdiff.c
usr.bin/spell/spellprog.c
usr.bin/split/split.c
usr.bin/ssh/scp.c
usr.bin/ssh/sftp-client.c
usr.bin/tmux/cmd-pipe-pane.c
usr.bin/tmux/job.c
usr.bin/vi/cl/cl_main.c
usr.bin/vi/common/exf.c
usr.bin/vi/common/main.c
usr.bin/vi/common/recover.c
usr.bin/vi/ex/ex_init.c
usr.bin/vi/ex/ex_source.c
usr.bin/vi/ex/ex_tag.c
usr.bin/wall/ttymsg.c
usr.bin/wc/wc.c
usr.bin/write/write.c
usr.bin/xinstall/xinstall.c
usr.sbin/config/exec_elf.c
usr.sbin/cron/atrun.c
usr.sbin/crunchgen/crunchgen.c
usr.sbin/dhcpd/pfutils.c
usr.sbin/dhcrelay/dhcrelay.c
usr.sbin/dhcrelay6/dhcrelay6.c
usr.sbin/eeprom/ophandlers.c
usr.sbin/eeprom/optree.c
usr.sbin/ftp-proxy/ftp-proxy.c
usr.sbin/installboot/i386_nlist.c
usr.sbin/installboot/i386_softraid.c
usr.sbin/kvm_mkdb/kvm_mkdb.c
usr.sbin/ldomctl/ldomctl.c
usr.sbin/ldomd/ds.c
usr.sbin/ldomd/ldomd.c
usr.sbin/lpd/printer.c
usr.sbin/lpr/lpd/printjob.c
usr.sbin/makefs/ffs.c
usr.sbin/mopd/mopchk/mopchk.c
usr.sbin/mopd/mopd/process.c
usr.sbin/mtree/compare.c
usr.sbin/mtree/create.c
usr.sbin/ntpd/ntp.c
usr.sbin/ntpd/ntp_dns.c
usr.sbin/pcidump/pcidump.c
usr.sbin/pppd/main.c
usr.sbin/pppd/sys-bsd.c
usr.sbin/pwd_mkdb/pwd_mkdb.c
usr.sbin/rbootd/rmpproto.c
usr.sbin/rdsetroot/rdsetroot.c
usr.sbin/rpki-client/main.c
usr.sbin/sa/main.c
usr.sbin/sasyncd/conf.y
usr.sbin/syslogd/privsep.c
usr.sbin/syslogd/syslogd.c
usr.sbin/tcpdump/privsep.c
usr.sbin/tftpd/tftpd.c
usr.sbin/vipw/vipw.c
usr.sbin/wsconscfg/wsconscfg.c
usr.sbin/wsfontload/wsfontload.c
usr.sbin/wsmoused/wsmoused.c