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

Side by Side Diff: content/public/common/common_param_traits.cc

Issue 11617006: Add some bounds for gfx ipc deserialization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « no previous file | 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 "content/public/common/common_param_traits.h" 5 #include "content/public/common/common_param_traits.h"
6 6
7 #include "content/public/common/content_constants.h" 7 #include "content/public/common/content_constants.h"
8 #include "content/public/common/referrer.h" 8 #include "content/public/common/referrer.h"
9 #include "net/base/host_port_pair.h" 9 #include "net/base/host_port_pair.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 r->set_x(x); 162 r->set_x(x);
163 r->set_y(y); 163 r->set_y(y);
164 return true; 164 return true;
165 } 165 }
166 166
167 void ParamTraits<gfx::PointF>::Log(const gfx::PointF& v, std::string* l) { 167 void ParamTraits<gfx::PointF>::Log(const gfx::PointF& v, std::string* l) {
168 l->append(base::StringPrintf("(%f, %f)", v.x(), v.y())); 168 l->append(base::StringPrintf("(%f, %f)", v.x(), v.y()));
169 } 169 }
170 170
171 void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) { 171 void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) {
172 DCHECK_GE(p.width(), 0);
173 DCHECK_GE(p.height(), 0);
172 m->WriteInt(p.width()); 174 m->WriteInt(p.width());
173 m->WriteInt(p.height()); 175 m->WriteInt(p.height());
174 } 176 }
175 177
176 bool ParamTraits<gfx::Size>::Read(const Message* m, 178 bool ParamTraits<gfx::Size>::Read(const Message* m,
177 PickleIterator* iter, 179 PickleIterator* iter,
178 gfx::Size* r) { 180 gfx::Size* r) {
179 int w, h; 181 int w, h;
180 if (!m->ReadInt(iter, &w) || 182 if (!m->ReadInt(iter, &w) || w < 0 ||
181 !m->ReadInt(iter, &h)) 183 !m->ReadInt(iter, &h) || h < 0)
182 return false; 184 return false;
183 r->set_width(w); 185 r->set_width(w);
184 r->set_height(h); 186 r->set_height(h);
185 return true; 187 return true;
186 } 188 }
187 189
188 void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::string* l) { 190 void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::string* l) {
189 l->append(base::StringPrintf("(%d, %d)", p.width(), p.height())); 191 l->append(base::StringPrintf("(%d, %d)", p.width(), p.height()));
190 } 192 }
191 193
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 r->set_x(x); 248 r->set_x(x);
247 r->set_y(y); 249 r->set_y(y);
248 return true; 250 return true;
249 } 251 }
250 252
251 void ParamTraits<gfx::Vector2dF>::Log(const gfx::Vector2dF& v, std::string* l) { 253 void ParamTraits<gfx::Vector2dF>::Log(const gfx::Vector2dF& v, std::string* l) {
252 l->append(base::StringPrintf("(%f, %f)", v.x(), v.y())); 254 l->append(base::StringPrintf("(%f, %f)", v.x(), v.y()));
253 } 255 }
254 256
255 void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) { 257 void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) {
256 m->WriteInt(p.x()); 258 WriteParam(m, p.origin());
257 m->WriteInt(p.y()); 259 WriteParam(m, p.size());
258 m->WriteInt(p.width());
259 m->WriteInt(p.height());
260 } 260 }
261 261
262 bool ParamTraits<gfx::Rect>::Read(const Message* m, 262 bool ParamTraits<gfx::Rect>::Read(const Message* m,
263 PickleIterator* iter, 263 PickleIterator* iter,
264 gfx::Rect* r) { 264 gfx::Rect* r) {
265 int x, y, w, h; 265 gfx::Point origin;
266 if (!m->ReadInt(iter, &x) || 266 gfx::Size size;
267 !m->ReadInt(iter, &y) || 267 if (!ReadParam(m, iter, &origin) ||
268 !m->ReadInt(iter, &w) || 268 !ReadParam(m, iter, &size))
269 !m->ReadInt(iter, &h))
270 return false; 269 return false;
271 r->set_x(x); 270 r->set_origin(origin);
272 r->set_y(y); 271 r->set_size(size);
273 r->set_width(w);
274 r->set_height(h);
275 return true; 272 return true;
276 } 273 }
277 274
278 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) { 275 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) {
279 l->append(base::StringPrintf("(%d, %d, %d, %d)", p.x(), p.y(), 276 l->append(base::StringPrintf("(%d, %d, %d, %d)", p.x(), p.y(),
280 p.width(), p.height())); 277 p.width(), p.height()));
281 } 278 }
282 279
283 void ParamTraits<gfx::RectF>::Write(Message* m, const gfx::RectF& p) { 280 void ParamTraits<gfx::RectF>::Write(Message* m, const gfx::RectF& p) {
284 ParamTraits<float>::Write(m, p.x()); 281 ParamTraits<float>::Write(m, p.x());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ 361 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
365 #include "content/public/common/common_param_traits_macros.h" 362 #include "content/public/common/common_param_traits_macros.h"
366 } // namespace IPC 363 } // namespace IPC
367 364
368 // Generate param traits log methods. 365 // Generate param traits log methods.
369 #include "ipc/param_traits_log_macros.h" 366 #include "ipc/param_traits_log_macros.h"
370 namespace IPC { 367 namespace IPC {
371 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ 368 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_
372 #include "content/public/common/common_param_traits_macros.h" 369 #include "content/public/common/common_param_traits_macros.h"
373 } // namespace IPC 370 } // namespace IPC
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698