summaryrefslogtreecommitdiffstats
path: root/native_client_sdk/src/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'native_client_sdk/src/libraries')
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_handle.cc5
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc5
-rw-r--r--native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc4
3 files changed, 10 insertions, 4 deletions
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc b/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
index f7bf163..4f88bbf 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_handle.cc
@@ -44,6 +44,11 @@ Error KernelHandle::Init(int open_flags) {
return EACCES;
}
+ // Directories can only be opened read-only.
+ if ((open_flags & 3) != O_RDONLY && node_->IsaDir()) {
+ return EISDIR;
+ }
+
if (open_flags & O_APPEND) {
Error error = node_->GetSize(&handle_attr_.offs);
if (error)
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
index 89c8e36..0837647 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
@@ -792,6 +792,11 @@ int KernelProxy::truncate(const char* path, off_t len) {
return -1;
}
+ // Directories cannot be truncated.
+ if (node->IsaDir()) {
+ return EISDIR;
+ }
+
if (!node->CanOpen(O_WRONLY)) {
errno = EACCES;
return -1;
diff --git a/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc b/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc
index 38c5070..70da25c 100644
--- a/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc
+++ b/native_client_sdk/src/libraries/nacl_io/memfs/mem_fs.cc
@@ -105,10 +105,6 @@ Error MemFs::OpenWithMode(const Path& path, int open_flags, mode_t mode,
} else {
// Opening an existing file.
- // Directories can only be opened read-only.
- if (node->IsaDir() && (open_flags & 3) != O_RDONLY)
- return EISDIR;
-
// If we were expected to create it exclusively, fail
if (open_flags & O_EXCL)
return EEXIST;