diff options
Diffstat (limited to 'usr/src/uts/common/syscall/getdents.c')
-rw-r--r-- | usr/src/uts/common/syscall/getdents.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/usr/src/uts/common/syscall/getdents.c b/usr/src/uts/common/syscall/getdents.c index da91808e74..944c9321aa 100644 --- a/usr/src/uts/common/syscall/getdents.c +++ b/usr/src/uts/common/syscall/getdents.c @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -93,6 +93,10 @@ getdents32(int fd, void *buf, size_t count) releasef(fd); return (set_errno(ENOTDIR)); } + if (!(fp->f_flag & FREAD)) { + releasef(fd); + return (set_errno(EBADF)); + } /* * Don't let the user overcommit kernel resources. @@ -207,6 +211,10 @@ getdents64(int fd, void *buf, size_t count) releasef(fd); return (set_errno(ENOTDIR)); } + if (!(fp->f_flag & FREAD)) { + releasef(fd); + return (set_errno(EBADF)); + } aiov.iov_base = buf; aiov.iov_len = count; auio.uio_iov = &aiov; |