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

Side by Side Diff: media/filters/h264_bit_reader.cc

Issue 1865203002: Avoid integer overflow errors when parsing Exp-Golomb codes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 1u 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 unified diff | Download patch
« no previous file with comments | « no previous file | media/filters/h264_parser.cc » ('j') | media/filters/h264_parser.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "media/filters/h264_bit_reader.h" 6 #include "media/filters/h264_bit_reader.h"
7 7
8 namespace media { 8 namespace media {
9 9
10 H264BitReader::H264BitReader() 10 H264BitReader::H264BitReader()
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 while (num_remaining_bits_in_curr_byte_ < bits_left) { 72 while (num_remaining_bits_in_curr_byte_ < bits_left) {
73 // Take all that's left in current byte, shift to make space for the rest. 73 // Take all that's left in current byte, shift to make space for the rest.
74 *out |= (curr_byte_ << (bits_left - num_remaining_bits_in_curr_byte_)); 74 *out |= (curr_byte_ << (bits_left - num_remaining_bits_in_curr_byte_));
75 bits_left -= num_remaining_bits_in_curr_byte_; 75 bits_left -= num_remaining_bits_in_curr_byte_;
76 76
77 if (!UpdateCurrByte()) 77 if (!UpdateCurrByte())
78 return false; 78 return false;
79 } 79 }
80 80
81 *out |= (curr_byte_ >> (num_remaining_bits_in_curr_byte_ - bits_left)); 81 *out |= (curr_byte_ >> (num_remaining_bits_in_curr_byte_ - bits_left));
82 *out &= ((1 << num_bits) - 1); 82 *out &= ((1u << num_bits) - 1);
sandersd (OOO until July 31) 2016/04/07 20:48:09 Both should be 1u.
jrummell 2016/04/07 21:13:59 Done.
83 num_remaining_bits_in_curr_byte_ -= bits_left; 83 num_remaining_bits_in_curr_byte_ -= bits_left;
84 84
85 return true; 85 return true;
86 } 86 }
87 87
88 off_t H264BitReader::NumBitsLeft() { 88 off_t H264BitReader::NumBitsLeft() {
89 return (num_remaining_bits_in_curr_byte_ + bytes_left_ * 8); 89 return (num_remaining_bits_in_curr_byte_ + bytes_left_ * 8);
90 } 90 }
91 91
92 bool H264BitReader::HasMoreRBSPData() { 92 bool H264BitReader::HasMoreRBSPData() {
(...skipping 20 matching lines...) Expand all
113 113
114 bytes_left_ = 0; 114 bytes_left_ = 0;
115 return false; 115 return false;
116 } 116 }
117 117
118 size_t H264BitReader::NumEmulationPreventionBytesRead() { 118 size_t H264BitReader::NumEmulationPreventionBytesRead() {
119 return emulation_prevention_bytes_; 119 return emulation_prevention_bytes_;
120 } 120 }
121 121
122 } // namespace media 122 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/filters/h264_parser.cc » ('j') | media/filters/h264_parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698