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

Unified 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, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/cc_messages_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/common/common_param_traits.cc
===================================================================
--- content/public/common/common_param_traits.cc (revision 175167)
+++ content/public/common/common_param_traits.cc (working copy)
@@ -4,6 +4,8 @@
#include "content/public/common/common_param_traits.h"
+#include <limits>
+
#include "content/public/common/content_constants.h"
#include "content/public/common/referrer.h"
#include "net/base/host_port_pair.h"
@@ -177,8 +179,9 @@
PickleIterator* iter,
gfx::Size* r) {
int w, h;
- if (!m->ReadInt(iter, &w) ||
- !m->ReadInt(iter, &h))
+ if (!m->ReadInt(iter, &w) || w < 0 ||
+ !m->ReadInt(iter, &h) || h < 0 ||
+ (h && w > ((std::numeric_limits<int>::max() / 4) / h)))
danakj 2013/01/07 19:19:03 We already DCHECK that sizes have positive values
danakj 2013/01/07 19:21:52 Actually maybe we don't. I landed that CL but it w
jschuh 2013/01/07 22:24:14 I understand that generally, but in security sensi
jschuh 2013/01/07 22:24:14 Yep.
danakj 2013/01/07 22:56:37 Sure, I'm just not sure why you see something like
jschuh 2013/01/08 00:08:45 I appreciate that it seems arbitrary, but it's the
jschuh 2013/01/08 00:43:32 Antoine provided some context in was lacking (in t
return false;
r->set_width(w);
r->set_height(h);
@@ -265,8 +268,9 @@
int x, y, w, h;
if (!m->ReadInt(iter, &x) ||
!m->ReadInt(iter, &y) ||
- !m->ReadInt(iter, &w) ||
- !m->ReadInt(iter, &h))
+ !m->ReadInt(iter, &w) || w < 0 ||
+ !m->ReadInt(iter, &h) || h < 0 ||
+ (h && w > ((std::numeric_limits<int>::max() / 4) / h)))
piman 2013/01/07 19:05:56 nit: it would be even better to serialize p.origin
jschuh 2013/01/07 22:24:14 Yep.
return false;
r->set_x(x);
r->set_y(y);
« no previous file with comments | « content/common/cc_messages_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698