Commit 50522283 authored by jschuh@chromium.org's avatar jschuh@chromium.org

Add some bounds for gfx ipc deserialization.

BUG=167680

Review URL: https://chromiumcodereview.appspot.com/11617006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175496 0039d316-1c4b-4281-b951-d872f2087c98
parent c7492db6
...@@ -169,6 +169,8 @@ void ParamTraits<gfx::PointF>::Log(const gfx::PointF& v, std::string* l) { ...@@ -169,6 +169,8 @@ void ParamTraits<gfx::PointF>::Log(const gfx::PointF& v, std::string* l) {
} }
void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) { 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.width());
m->WriteInt(p.height()); m->WriteInt(p.height());
} }
...@@ -177,8 +179,8 @@ bool ParamTraits<gfx::Size>::Read(const Message* m, ...@@ -177,8 +179,8 @@ bool ParamTraits<gfx::Size>::Read(const Message* m,
PickleIterator* iter, PickleIterator* iter,
gfx::Size* r) { gfx::Size* r) {
int w, h; int w, h;
if (!m->ReadInt(iter, &w) || if (!m->ReadInt(iter, &w) || w < 0 ||
!m->ReadInt(iter, &h)) !m->ReadInt(iter, &h) || h < 0)
return false; return false;
r->set_width(w); r->set_width(w);
r->set_height(h); r->set_height(h);
...@@ -253,25 +255,20 @@ void ParamTraits<gfx::Vector2dF>::Log(const gfx::Vector2dF& v, std::string* l) { ...@@ -253,25 +255,20 @@ void ParamTraits<gfx::Vector2dF>::Log(const gfx::Vector2dF& v, std::string* l) {
} }
void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) { void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) {
m->WriteInt(p.x()); WriteParam(m, p.origin());
m->WriteInt(p.y()); WriteParam(m, p.size());
m->WriteInt(p.width());
m->WriteInt(p.height());
} }
bool ParamTraits<gfx::Rect>::Read(const Message* m, bool ParamTraits<gfx::Rect>::Read(const Message* m,
PickleIterator* iter, PickleIterator* iter,
gfx::Rect* r) { gfx::Rect* r) {
int x, y, w, h; gfx::Point origin;
if (!m->ReadInt(iter, &x) || gfx::Size size;
!m->ReadInt(iter, &y) || if (!ReadParam(m, iter, &origin) ||
!m->ReadInt(iter, &w) || !ReadParam(m, iter, &size))
!m->ReadInt(iter, &h))
return false; return false;
r->set_x(x); r->set_origin(origin);
r->set_y(y); r->set_size(size);
r->set_width(w);
r->set_height(h);
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment