summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorguenther <>2015-05-11 00:42:54 +0000
committerguenther <>2015-05-11 00:42:54 +0000
commitb37fedd6c323434f4c0c0fad5aca107223c4740a (patch)
tree1c9a8bc502e9cd3fa947cda84fcc8238a6187c59
parent8db0b019d8a8eba0b284550a1b273359a1f7124a (diff)
downloadopenbsd-b37fedd6c323434f4c0c0fad5aca107223c4740a.tar.gz
openbsd-b37fedd6c323434f4c0c0fad5aca107223c4740a.tar.bz2
openbsd-b37fedd6c323434f4c0c0fad5aca107223c4740a.zip
When checking flags that will be passed to open(), test the O_ACCMODE portion
separately to avoid false negatives. ok miod@ millert@
-rw-r--r--src/lib/libc/stdlib/posix_pty.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/libc/stdlib/posix_pty.c b/src/lib/libc/stdlib/posix_pty.c
index a2025ddbb6..72b5d527cc 100644
--- a/src/lib/libc/stdlib/posix_pty.c
+++ b/src/lib/libc/stdlib/posix_pty.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: posix_pty.c,v 1.1 2012/12/03 20:08:33 millert Exp $ */ 1/* $OpenBSD: posix_pty.c,v 1.2 2015/05/11 00:42:54 guenther Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2012 Todd C. Miller <Todd.Miller@courtesan.com> 4 * Copyright (c) 2012 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -35,7 +35,8 @@ posix_openpt(int oflag)
35 int fd, mfd = -1; 35 int fd, mfd = -1;
36 36
37 /* User must specify O_RDWR in oflag. */ 37 /* User must specify O_RDWR in oflag. */
38 if (!(oflag & O_RDWR)) { 38 if ((oflag & O_ACCMODE) != O_RDWR ||
39 (oflag & ~(O_ACCMODE | O_NOCTTY)) != 0) {
39 errno = EINVAL; 40 errno = EINVAL;
40 return -1; 41 return -1;
41 } 42 }