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

Side by Side Diff: ipc/ipc_message_utils.cc

Issue 2570113002: Increase the depth limit of JSONParser and IPC serialization from 100 to 200. (Closed)
Patch Set: added comment Created 3 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
« no previous file with comments | « components/safe_json/json_sanitizer_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 "ipc/ipc_message_utils.h" 5 #include "ipc/ipc_message_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 25 matching lines...) Expand all
36 36
37 #if defined(OS_WIN) 37 #if defined(OS_WIN)
38 #include <tchar.h> 38 #include <tchar.h>
39 #include "ipc/handle_win.h" 39 #include "ipc/handle_win.h"
40 #endif 40 #endif
41 41
42 namespace IPC { 42 namespace IPC {
43 43
44 namespace { 44 namespace {
45 45
46 const int kMaxRecursionDepth = 100; 46 const int kMaxRecursionDepth = 200;
47 47
48 template<typename CharType> 48 template<typename CharType>
49 void LogBytes(const std::vector<CharType>& data, std::string* out) { 49 void LogBytes(const std::vector<CharType>& data, std::string* out) {
50 #if defined(OS_WIN) 50 #if defined(OS_WIN)
51 // Windows has a GUI for logging, which can handle arbitrary binary data. 51 // Windows has a GUI for logging, which can handle arbitrary binary data.
52 for (size_t i = 0; i < data.size(); ++i) 52 for (size_t i = 0; i < data.size(); ++i)
53 out->push_back(data[i]); 53 out->push_back(data[i]);
54 #else 54 #else
55 // On POSIX, we log to stdout, which we assume can display ASCII. 55 // On POSIX, we log to stdout, which we assume can display ASCII.
56 static const size_t kMaxBytesToLog = 100; 56 static const size_t kMaxBytesToLog = 100;
(...skipping 14 matching lines...) Expand all
71 71
72 bool ReadValue(const base::Pickle* m, 72 bool ReadValue(const base::Pickle* m,
73 base::PickleIterator* iter, 73 base::PickleIterator* iter,
74 base::Value** value, 74 base::Value** value,
75 int recursion); 75 int recursion);
76 76
77 void GetValueSize(base::PickleSizer* sizer, 77 void GetValueSize(base::PickleSizer* sizer,
78 const base::Value* value, 78 const base::Value* value,
79 int recursion) { 79 int recursion) {
80 if (recursion > kMaxRecursionDepth) { 80 if (recursion > kMaxRecursionDepth) {
81 LOG(WARNING) << "Max recursion depth hit in GetValueSize."; 81 LOG(ERROR) << "Max recursion depth hit in GetValueSize.";
82 return; 82 return;
83 } 83 }
84 84
85 sizer->AddInt(); 85 sizer->AddInt();
86 switch (value->GetType()) { 86 switch (value->GetType()) {
87 case base::Value::Type::NONE: 87 case base::Value::Type::NONE:
88 break; 88 break;
89 case base::Value::Type::BOOLEAN: 89 case base::Value::Type::BOOLEAN:
90 sizer->AddBool(); 90 sizer->AddBool();
91 break; 91 break;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 break; 135 break;
136 } 136 }
137 default: 137 default:
138 NOTREACHED() << "Invalid base::Value type."; 138 NOTREACHED() << "Invalid base::Value type.";
139 } 139 }
140 } 140 }
141 141
142 void WriteValue(base::Pickle* m, const base::Value* value, int recursion) { 142 void WriteValue(base::Pickle* m, const base::Value* value, int recursion) {
143 bool result; 143 bool result;
144 if (recursion > kMaxRecursionDepth) { 144 if (recursion > kMaxRecursionDepth) {
145 LOG(WARNING) << "Max recursion depth hit in WriteValue."; 145 LOG(ERROR) << "Max recursion depth hit in WriteValue.";
146 return; 146 return;
147 } 147 }
148 148
149 m->WriteInt(static_cast<int>(value->GetType())); 149 m->WriteInt(static_cast<int>(value->GetType()));
150 150
151 switch (value->GetType()) { 151 switch (value->GetType()) {
152 case base::Value::Type::NONE: 152 case base::Value::Type::NONE:
153 break; 153 break;
154 case base::Value::Type::BOOLEAN: { 154 case base::Value::Type::BOOLEAN: {
155 bool val; 155 bool val;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 249 }
250 250
251 return true; 251 return true;
252 } 252 }
253 253
254 bool ReadValue(const base::Pickle* m, 254 bool ReadValue(const base::Pickle* m,
255 base::PickleIterator* iter, 255 base::PickleIterator* iter,
256 base::Value** value, 256 base::Value** value,
257 int recursion) { 257 int recursion) {
258 if (recursion > kMaxRecursionDepth) { 258 if (recursion > kMaxRecursionDepth) {
259 LOG(WARNING) << "Max recursion depth hit in ReadValue."; 259 LOG(ERROR) << "Max recursion depth hit in ReadValue.";
260 return false; 260 return false;
261 } 261 }
262 262
263 int type; 263 int type;
264 if (!ReadParam(m, iter, &type)) 264 if (!ReadParam(m, iter, &type))
265 return false; 265 return false;
266 266
267 switch (static_cast<base::Value::Type>(type)) { 267 switch (static_cast<base::Value::Type>(type)) {
268 case base::Value::Type::NONE: 268 case base::Value::Type::NONE:
269 *value = base::Value::CreateNullValue().release(); 269 *value = base::Value::CreateNullValue().release();
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 return result; 1233 return result;
1234 } 1234 }
1235 1235
1236 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { 1236 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) {
1237 l->append("<MSG>"); 1237 l->append("<MSG>");
1238 } 1238 }
1239 1239
1240 #endif // OS_WIN 1240 #endif // OS_WIN
1241 1241
1242 } // namespace IPC 1242 } // namespace IPC
OLDNEW
« no previous file with comments | « components/safe_json/json_sanitizer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698