From be4ab66a3737ed365484a540057baea50378ba4a Mon Sep 17 00:00:00 2001 From: guenther <> Date: Mon, 11 May 2015 00:42:54 +0000 Subject: When checking flags that will be passed to open(), test the O_ACCMODE portion separately to avoid false negatives. ok miod@ millert@ --- src/lib/libc/stdlib/posix_pty.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') 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 @@ -/* $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 @@ -35,7 +35,8 @@ posix_openpt(int oflag) 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; } -- cgit v1.2.3-55-g6feb