summaryrefslogtreecommitdiffstats
path: root/dbus/message.cc
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-05 04:15:50 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-05 04:15:50 +0000
commit43fa5b848147d846761fecbea0317331510dd287 (patch)
treeeae5721b0ae1bd1fb4be7d93e66266a0b2b2beca /dbus/message.cc
parent44437a2af771d8302a128a38aa25953ce7eaa51f (diff)
downloadchromium_src-43fa5b848147d846761fecbea0317331510dd287.zip
chromium_src-43fa5b848147d846761fecbea0317331510dd287.tar.gz
chromium_src-43fa5b848147d846761fecbea0317331510dd287.tar.bz2
Explicitly CHECK arguments in dbus::MessageWriter::AppendString/ObjectPath
Add dbus::IsStringValidObjectPath() and dbus::ObjectPath::IsValid() BUG=129335 TEST=dbus_unittests Review URL: https://chromiumcodereview.appspot.com/10502011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140489 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/message.cc')
-rw-r--r--dbus/message.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/dbus/message.cc b/dbus/message.cc
index 5b45d42..2caf543 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);
}