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

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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | 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)
@@ -169,6 +169,8 @@
}
void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) {
+ DCHECK_GE(p.width(), 0);
+ DCHECK_GE(p.height(), 0);
m->WriteInt(p.width());
m->WriteInt(p.height());
}
@@ -177,8 +179,8 @@
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)
return false;
r->set_width(w);
r->set_height(h);
@@ -253,25 +255,20 @@
}
void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) {
- m->WriteInt(p.x());
- m->WriteInt(p.y());
- m->WriteInt(p.width());
- m->WriteInt(p.height());
+ WriteParam(m, p.origin());
+ WriteParam(m, p.size());
}
bool ParamTraits<gfx::Rect>::Read(const Message* m,
PickleIterator* iter,
gfx::Rect* r) {
- int x, y, w, h;
- if (!m->ReadInt(iter, &x) ||
- !m->ReadInt(iter, &y) ||
- !m->ReadInt(iter, &w) ||
- !m->ReadInt(iter, &h))
+ gfx::Point origin;
+ gfx::Size size;
+ if (!ReadParam(m, iter, &origin) ||
+ !ReadParam(m, iter, &size))
return false;
- r->set_x(x);
- r->set_y(y);
- r->set_width(w);
- r->set_height(h);
+ r->set_origin(origin);
+ r->set_size(size);
return true;
}
« 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