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

Side by Side Diff: ipc/ipc_message_utils_unittest.cc

Issue 11642041: Don't allow '\0' characters in FilePath. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments, check that FPS() works Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« base/file_path.cc ('K') | « base/file_path_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/file_path.h" 5 #include "base/file_path.h"
6 #include "ipc/ipc_message.h" 6 #include "ipc/ipc_message.h"
7 #include "ipc/ipc_message_utils.h" 7 #include "ipc/ipc_message_utils.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace IPC { 10 namespace IPC {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // Try reading past the ends for both messages and make sure it fails. 47 // Try reading past the ends for both messages and make sure it fails.
48 IPC::Message dummy; 48 IPC::Message dummy;
49 ASSERT_FALSE(ParamTraits<Message>::Read(&outer_msg, &iter, &dummy)); 49 ASSERT_FALSE(ParamTraits<Message>::Read(&outer_msg, &iter, &dummy));
50 ASSERT_FALSE(ParamTraits<int>::Read(&nested_msg, &nested_iter, 50 ASSERT_FALSE(ParamTraits<int>::Read(&nested_msg, &nested_iter,
51 &result_content)); 51 &result_content));
52 } 52 }
53 53
54 // Tests that detection of various bad parameters is working correctly. 54 // Tests that detection of various bad parameters is working correctly.
55 TEST(IPCMessageUtilsTest, ParameterValidation) { 55 TEST(IPCMessageUtilsTest, ParameterValidation) {
56 IPC::Message message;
57 FilePath::StringType okString(FILE_PATH_LITERAL("hello"), 5); 56 FilePath::StringType okString(FILE_PATH_LITERAL("hello"), 5);
58 FilePath::StringType badString(FILE_PATH_LITERAL("hel\0o"), 5); 57 FilePath::StringType badString(FILE_PATH_LITERAL("hel\0o"), 5);
59 FilePath okPath(okString); 58
60 FilePath badPath(badString); 59 // Change this if ParamTraits<FilePath>::Write() changes.
61 ParamTraits<FilePath>::Write(&message, okPath); 60 IPC::Message message;
62 ParamTraits<FilePath>::Write(&message, badPath); 61 ParamTraits<FilePath::StringType>::Write(&message, okString);
62 ParamTraits<FilePath::StringType>::Write(&message, badString);
63 63
64 PickleIterator iter(message); 64 PickleIterator iter(message);
65 FilePath okPath;
66 FilePath badPath;
65 ASSERT_TRUE(ParamTraits<FilePath>::Read(&message, &iter, &okPath)); 67 ASSERT_TRUE(ParamTraits<FilePath>::Read(&message, &iter, &okPath));
66 ASSERT_FALSE(ParamTraits<FilePath>::Read(&message, &iter, &badPath)); 68 ASSERT_FALSE(ParamTraits<FilePath>::Read(&message, &iter, &badPath));
67 } 69 }
68 70
69 } // namespace IPC 71 } // namespace IPC
OLDNEW
« base/file_path.cc ('K') | « base/file_path_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698