separately to avoid false negatives.
ok miod@ millert@
-/* $OpenBSD: db.c,v 1.10 2005/08/05 13:03:00 espie Exp $ */
+/* $OpenBSD: db.c,v 1.11 2015/05/11 00:42:54 guenther Exp $ */
/*-
* Copyright (c) 1991, 1993
#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN)
#define USE_OPEN_FLAGS \
(O_CREAT | O_EXCL | O_EXLOCK | O_NOFOLLOW | O_NONBLOCK | \
- O_RDONLY | O_RDWR | O_SHLOCK | O_SYNC | O_TRUNC)
+ O_SHLOCK | O_SYNC | O_TRUNC)
- if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0)
+ if (((flags & O_ACCMODE) == O_RDONLY || (flags & O_ACCMODE) == O_RDWR)
+ && (flags & ~(O_ACCMODE | USE_OPEN_FLAGS | DB_FLAGS)) == 0)
switch (type) {
case DB_BTREE:
return (__bt_open(fname, flags & USE_OPEN_FLAGS,
-/* $OpenBSD: shm_open.c,v 1.4 2013/11/12 06:09:48 deraadt Exp $ */
+/* $OpenBSD: shm_open.c,v 1.5 2015/05/11 00:42:54 guenther Exp $ */
/*
* Copyright (c) 2013 Ted Unangst <tedu@openbsd.org>
*
/* "/tmp/" + sha256 + ".shm" */
#define SHM_PATH_SIZE (5 + SHA256_DIGEST_STRING_LENGTH + 4)
+/* O_CLOEXEC and O_NOFOLLOW are extensions to POSIX */
+#define OK_FLAGS (O_CREAT | O_EXCL | O_TRUNC | O_CLOEXEC | O_NOFOLLOW)
+
static void
makeshmpath(const char *origpath, char *shmpath, size_t len)
{
struct stat sb;
int fd;
- if (flags & ~(O_RDONLY | O_RDWR |
- O_CREAT | O_EXCL | O_TRUNC | O_CLOEXEC | O_NOFOLLOW)) {
+ if (((flags & O_ACCMODE) != O_RDONLY && (flags & O_ACCMODE) != O_RDWR)
+ || (flags & ~(O_ACCMODE | OK_FLAGS))) {
errno = EINVAL;
return -1;
}
-/* $OpenBSD: posix_pty.c,v 1.1 2012/12/03 20:08:33 millert Exp $ */
+/* $OpenBSD: posix_pty.c,v 1.2 2015/05/11 00:42:54 guenther Exp $ */
/*
* Copyright (c) 2012 Todd C. Miller <Todd.Miller@courtesan.com>
int fd, mfd = -1;
/* User must specify O_RDWR in oflag. */
- if (!(oflag & O_RDWR)) {
+ if ((oflag & O_ACCMODE) != O_RDWR ||
+ (oflag & ~(O_ACCMODE | O_NOCTTY)) != 0) {
errno = EINVAL;
return -1;
}
-/* $OpenBSD: kvm.c,v 1.54 2015/01/16 16:48:51 deraadt Exp $ */
+/* $OpenBSD: kvm.c,v 1.55 2015/05/11 00:42:54 guenther Exp $ */
/* $NetBSD: kvm.c,v 1.43 1996/05/05 04:31:59 gwr Exp $ */
/*-
_kvm_err(kd, kd->program, "exec file name too long");
goto failed;
}
- if (flag & ~O_ACCMODE) {
+ if (flag != O_RDONLY && flag != O_WRONLY && flag != O_RDWR) {
_kvm_err(kd, kd->program, "bad flags arg");
goto failed;
}