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

Unified Diff: webrtc/modules/video_coding/utility/vp8_header_parser.cc

Issue 1888313002: Fix the issue of undefined-shift in VP8GetBit. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/utility/vp8_header_parser.cc
diff --git a/webrtc/modules/video_coding/utility/vp8_header_parser.cc b/webrtc/modules/video_coding/utility/vp8_header_parser.cc
index 631385d0f25095903e676f79dc24e04ea1e1c6cd..5028ade6cf5dc391b9a0db5574725cac64616452 100644
--- a/webrtc/modules/video_coding/utility/vp8_header_parser.cc
+++ b/webrtc/modules/video_coding/utility/vp8_header_parser.cc
@@ -17,6 +17,7 @@ namespace vp8 {
namespace {
const size_t kCommonPayloadHeaderLength = 3;
const size_t kKeyPayloadHeaderLength = 10;
+const size_t kParseError = 0;
} // namespace
static uint32_t BSwap32(uint32_t x) {
@@ -78,6 +79,10 @@ static int VP8GetBit(VP8BitReader* const br, int prob) {
const int pos = br->bits_;
const uint8_t split = (range * prob) >> 8;
+ if (pos < 0) {
+ pos = 0;
pbos-webrtc 2016/04/15 08:58:58 Also log an error in here, but I think you should
jackychen_ 2016/04/15 20:24:50 Right, it must be an invalid bitstream.
+ kParseError = 1;
pbos-webrtc 2016/04/15 08:58:58 Does this even compile? You shouldn't modify globa
jackychen_ 2016/04/15 20:24:50 Done.
+ }
const uint8_t value = static_cast<uint8_t>(br->value_ >> pos);
int bit;
if (value > split) {
@@ -170,6 +175,7 @@ bool GetQp(const uint8_t* buf, size_t length, int* qp) {
// Size of first partition in bytes.
uint32_t partition_length = (bits >> 5);
size_t header_length = kCommonPayloadHeaderLength;
+ kParseError = 0;
pbos-webrtc 2016/04/15 08:58:58 Should this not be a property of the bitreader?
jackychen_ 2016/04/15 20:24:50 Done.
if (key_frame) {
header_length = kKeyPayloadHeaderLength;
}
@@ -196,6 +202,8 @@ bool GetQp(const uint8_t* buf, size_t length, int* qp) {
return false;
}
*qp = base_q0;
+ if (kParseError)
+ return false;
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