diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2014-10-27 20:02:59 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2014-10-27 20:02:59 +0000 |
commit | 95112a55ac4632d0f173f0137fb1cfe68d4f7af0 (patch) | |
tree | 92da15f3d9a59e2e479201fb8a8b5763e087092b | |
parent | a4e7431c1f3a244f057406d75c33f8dddb8901aa (diff) | |
download | illumos-joyent-95112a55ac4632d0f173f0137fb1cfe68d4f7af0.tar.gz |
OS-3473 lxbrand open with O_DIRECTORY can hang
-rw-r--r-- | usr/src/lib/brand/lx/lx_brand/common/open.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/usr/src/lib/brand/lx/lx_brand/common/open.c b/usr/src/lib/brand/lx/lx_brand/common/open.c index 62d7172eeb..0a643bf3ad 100644 --- a/usr/src/lib/brand/lx/lx_brand/common/open.c +++ b/usr/src/lib/brand/lx/lx_brand/common/open.c @@ -171,6 +171,24 @@ lx_open(uintptr_t p1, uintptr_t p2, uintptr_t p3) mode_t mode = 0; char *path = (char *)p1; + /* + * We'll check the file type again after opening the file (see the + * explanation in lx_open_postprocess), but we also need to check BEFORE + * to avoid the very hang O_DIRECTORY is trying to avoid for opendir(3) + * when given a FIFO. + */ + if (p2 & LX_O_DIRECTORY) { + struct stat64 statbuf; + + if (lstat64(path, &statbuf) < 0) { + return (-errno); + } + + if (!S_ISDIR(statbuf.st_mode)) { + return (-ENOTDIR); + } + } + flags = ltos_open_flags(p2); if (flags & O_CREAT) { |