diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-10 21:39:04 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-10 21:39:04 +0000 |
commit | aac449e7154720b895ff1e7f3497c2ce95ae1a5a (patch) | |
tree | 1964554316fe4b54cd0efa6ba471dd61467bfe39 /ipc/file_descriptor_set_posix.cc | |
parent | dc78796d35a53f758b2b6b729cf8a18034783d13 (diff) | |
download | chromium_src-aac449e7154720b895ff1e7f3497c2ce95ae1a5a.zip chromium_src-aac449e7154720b895ff1e7f3497c2ce95ae1a5a.tar.gz chromium_src-aac449e7154720b895ff1e7f3497c2ce95ae1a5a.tar.bz2 |
POSIX: make sure that we never pass directory descriptors into the sandbox.
BUG=43304
http://codereview.chromium.org/2733011/show
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49446 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/file_descriptor_set_posix.cc')
-rw-r--r-- | ipc/file_descriptor_set_posix.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ipc/file_descriptor_set_posix.cc b/ipc/file_descriptor_set_posix.cc index 519e6e7..3796fae 100644 --- a/ipc/file_descriptor_set_posix.cc +++ b/ipc/file_descriptor_set_posix.cc @@ -4,6 +4,9 @@ #include "ipc/file_descriptor_set_posix.h" +#include <sys/types.h> +#include <sys/stat.h> + #include "base/eintr_wrapper.h" #include "base/logging.h" @@ -94,6 +97,18 @@ void FileDescriptorSet::GetDescriptors(int* buffer) const { } } +bool FileDescriptorSet::ContainsDirectoryDescriptor() const { + struct stat st; + + for (std::vector<base::FileDescriptor>::const_iterator + i = descriptors_.begin(); i != descriptors_.end(); ++i) { + if (fstat(i->fd, &st) == 0 && S_ISDIR(st.st_mode)) + return true; + } + + return false; +} + void FileDescriptorSet::CommitAll() { for (std::vector<base::FileDescriptor>::iterator i = descriptors_.begin(); i != descriptors_.end(); ++i) { |