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

Unified Diff: content/common/gpu/media/h264_decoder.cc

Issue 1896533002: Check frame coded size in H264 parsers to avoid integer overflows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | media/formats/mp2t/es_parser_h264.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/h264_decoder.cc
diff --git a/content/common/gpu/media/h264_decoder.cc b/content/common/gpu/media/h264_decoder.cc
index 46ffa2a45085f0b554898ad149ef551696e38bc9..f8504f3c53cec01b970b2c8df04b13036a669172 100644
--- a/content/common/gpu/media/h264_decoder.cc
+++ b/content/common/gpu/media/h264_decoder.cc
@@ -1086,6 +1086,13 @@ bool H264Decoder::ProcessSPS(int sps_id, bool* need_new_buffers) {
int height_mb = (2 - sps->frame_mbs_only_flag) *
(sps->pic_height_in_map_units_minus1 + 1);
+ if (width_mb > std::numeric_limits<int>::max() / 16 ||
Pawel Osciak 2016/04/20 04:22:09 Could we perhaps use: base::IsValueInRangeForNumer
servolk 2016/04/20 17:32:53 Well, we are actually trying to avoid integer over
Pawel Osciak 2016/04/21 01:03:53 Yes, unless the result was of a larger type: int a
servolk 2016/04/21 01:24:06 First of all, you probably meant 16ull, as 16u is
+ height_mb > std::numeric_limits<int>::max() / 16) {
+ DVLOG(1) << "Picture size is too big: width_mb=" << width_mb
+ << " height_mb=" << height_mb;
+ return false;
+ }
+
gfx::Size new_pic_size(16 * width_mb, 16 * height_mb);
if (new_pic_size.IsEmpty()) {
DVLOG(1) << "Invalid picture size: " << new_pic_size.ToString();
« no previous file with comments | « no previous file | media/formats/mp2t/es_parser_h264.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698