Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Unified Diff: dbus/message.cc

Issue 10382021: dbus: revamp fd passing for i/o restrictions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: handle GetDebugLogs too Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: dbus/message.cc
diff --git a/dbus/message.cc b/dbus/message.cc
index d52591217e47bedadb04afcaf57dfcc5b3fcb435..400c1bcfd2a8e9bdfc083451757e8acad1b7d2b4 100644
--- a/dbus/message.cc
+++ b/dbus/message.cc
@@ -9,7 +9,6 @@
#include "base/basictypes.h"
#include "base/format_macros.h"
#include "base/logging.h"
-#include "base/platform_file.h"
#include "base/stringprintf.h"
#include "dbus/object_path.h"
#include "third_party/protobuf/src/google/protobuf/message_lite.h"
@@ -691,13 +690,11 @@ void MessageWriter::AppendVariantOfBasic(int dbus_type, const void* value) {
void MessageWriter::AppendFileDescriptor(const FileDescriptor& value) {
CHECK(kDBusTypeUnixFdIsSupported);
- base::PlatformFileInfo info;
- int fd = value.value();
- bool ok = base::GetPlatformFileInfo(fd, &info);
- if (!ok || info.is_directory) {
+ if (!value.is_valid()) {
// NB: sending a directory potentially enables sandbox escape
LOG(FATAL) << "Attempt to pass invalid file descriptor";
}
+ int fd = value.value();
AppendBasic(DBUS_TYPE_UNIX_FD, &fd);
}
@@ -968,15 +965,8 @@ bool MessageReader::PopFileDescriptor(FileDescriptor* value) {
if (!success)
return false;
- base::PlatformFileInfo info;
- bool ok = base::GetPlatformFileInfo(fd, &info);
- if (!ok || info.is_directory) {
- base::ClosePlatformFile(fd);
- // NB: receiving a directory potentially enables sandbox escape
- LOG(FATAL) << "Attempt to receive invalid file descriptor";
- return false; // NB: not reached
- }
value->PutValue(fd);
+ // NB: the caller must check validity before using the value
return true;
}
« dbus/file_descriptor.cc ('K') | « dbus/file_descriptor.cc ('k') | dbus/message_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698