summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authoraedla@chromium.org <aedla@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-28 13:47:55 +0000
committeraedla@chromium.org <aedla@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-28 13:47:55 +0000
commitaeae59f4a1f15e80b6a726734ca6190cf111eeee (patch)
tree1eddadd678a01096f582865fe9b003fdcbab5727 /ipc
parentde6912ddcad4b29b13a5592d331ebe29cd728924 (diff)
downloadchromium_src-aeae59f4a1f15e80b6a726734ca6190cf111eeee.zip
chromium_src-aeae59f4a1f15e80b6a726734ca6190cf111eeee.tar.gz
chromium_src-aeae59f4a1f15e80b6a726734ca6190cf111eeee.tar.bz2
Don't allow '\0' characters in FilePath.
BUG=169777 Review URL: https://chromiumcodereview.appspot.com/11642041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179141 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc')
-rw-r--r--ipc/ipc_message_utils.cc11
-rw-r--r--ipc/ipc_message_utils_unittest.cc18
2 files changed, 12 insertions, 17 deletions
diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc
index dd310c1..432853c 100644
--- a/ipc/ipc_message_utils.cc
+++ b/ipc/ipc_message_utils.cc
@@ -489,20 +489,13 @@ void ParamTraits<base::FileDescriptor>::Log(const param_type& p,
#endif // defined(OS_POSIX)
void ParamTraits<FilePath>::Write(Message* m, const param_type& p) {
- ParamTraits<FilePath::StringType>::Write(m, p.value());
+ p.WriteToPickle(m);
}
bool ParamTraits<FilePath>::Read(const Message* m,
PickleIterator* iter,
param_type* r) {
- FilePath::StringType value;
- if (!ParamTraits<FilePath::StringType>::Read(m, iter, &value))
- return false;
- // Reject embedded NULs as they can cause security checks to go awry.
- if (value.find(FILE_PATH_LITERAL('\0')) != FilePath::StringType::npos)
- return false;
- *r = FilePath(value);
- return true;
+ return r->ReadFromPickle(iter);
}
void ParamTraits<FilePath>::Log(const param_type& p, std::string* l) {
diff --git a/ipc/ipc_message_utils_unittest.cc b/ipc/ipc_message_utils_unittest.cc
index 2a49b9a..f9cb553 100644
--- a/ipc/ipc_message_utils_unittest.cc
+++ b/ipc/ipc_message_utils_unittest.cc
@@ -55,17 +55,19 @@ TEST(IPCMessageUtilsTest, NestedMessages) {
// Tests that detection of various bad parameters is working correctly.
TEST(IPCMessageUtilsTest, ParameterValidation) {
+ FilePath::StringType ok_string(FILE_PATH_LITERAL("hello"), 5);
+ FilePath::StringType bad_string(FILE_PATH_LITERAL("hel\0o"), 5);
+
+ // Change this if ParamTraits<FilePath>::Write() changes.
IPC::Message message;
- FilePath::StringType okString(FILE_PATH_LITERAL("hello"), 5);
- FilePath::StringType badString(FILE_PATH_LITERAL("hel\0o"), 5);
- FilePath okPath(okString);
- FilePath badPath(badString);
- ParamTraits<FilePath>::Write(&message, okPath);
- ParamTraits<FilePath>::Write(&message, badPath);
+ ParamTraits<FilePath::StringType>::Write(&message, ok_string);
+ ParamTraits<FilePath::StringType>::Write(&message, bad_string);
PickleIterator iter(message);
- ASSERT_TRUE(ParamTraits<FilePath>::Read(&message, &iter, &okPath));
- ASSERT_FALSE(ParamTraits<FilePath>::Read(&message, &iter, &badPath));
+ FilePath ok_path;
+ FilePath bad_path;
+ ASSERT_TRUE(ParamTraits<FilePath>::Read(&message, &iter, &ok_path));
+ ASSERT_FALSE(ParamTraits<FilePath>::Read(&message, &iter, &bad_path));
}
} // namespace