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

Unified Diff: dbus/message.cc

Issue 10502011: Explicitly CHECK arguments in dbus::MessageWriter::AppendString/ObjectPath (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix Created 8 years, 6 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
« no previous file with comments | « dbus/dbus.gyp ('k') | dbus/object_path.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/message.cc
diff --git a/dbus/message.cc b/dbus/message.cc
index 5b45d423908054ca051302b5012262875ae9635d..2caf543e2298f05288d0bededdcaba4a1f9b7431 100644
--- a/dbus/message.cc
+++ b/dbus/message.cc
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/format_macros.h"
#include "base/logging.h"
+#include "base/string_util.h"
#include "base/stringprintf.h"
#include "dbus/object_path.h"
#include "third_party/protobuf/src/google/protobuf/message_lite.h"
@@ -482,6 +483,8 @@ void MessageWriter::AppendDouble(double value) {
}
void MessageWriter::AppendString(const std::string& value) {
+ // D-Bus Specification (0.19) says a string "must be valid UTF-8".
+ CHECK(IsStringUTF8(value));
const char* pointer = value.c_str();
AppendBasic(DBUS_TYPE_STRING, &pointer);
// TODO(satorux): It may make sense to return an error here, as the
@@ -490,6 +493,7 @@ void MessageWriter::AppendString(const std::string& value) {
}
void MessageWriter::AppendObjectPath(const ObjectPath& value) {
+ CHECK(value.IsValid());
const char* pointer = value.value().c_str();
AppendBasic(DBUS_TYPE_OBJECT_PATH, &pointer);
}
« no previous file with comments | « dbus/dbus.gyp ('k') | dbus/object_path.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698