Prevent depacketizer OOB reads on zero-length VP8 payload.
BUG=webrtc:4771 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/1221643009 Cr-Commit-Position: refs/heads/master@{#9520}
This commit is contained in:
parent
6e355af348
commit
48c3839e70
@ -668,6 +668,10 @@ bool RtpDepacketizerVp8::Parse(ParsedPayload* parsed_payload,
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_data_length) {
|
||||
assert(parsed_payload != NULL);
|
||||
if (payload_data_length == 0) {
|
||||
LOG(LS_ERROR) << "Empty payload.";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Parse mandatory first byte of payload descriptor.
|
||||
bool extension = (*payload_data & 0x80) ? true : false; // X bit
|
||||
|
@ -596,4 +596,11 @@ TEST_F(RtpDepacketizerVp8Test, TestWithPacketizer) {
|
||||
EXPECT_EQ(payload.type.Video.codecHeader.VP8.layerSync,
|
||||
input_header.layerSync);
|
||||
}
|
||||
|
||||
TEST_F(RtpDepacketizerVp8Test, TestEmptyPayload) {
|
||||
// Using a wild pointer to crash on accesses from inside the depacketizer.
|
||||
uint8_t* garbage_ptr = reinterpret_cast<uint8_t*>(0x4711);
|
||||
RtpDepacketizer::ParsedPayload payload;
|
||||
EXPECT_FALSE(depacketizer_->Parse(&payload, garbage_ptr, 0));
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
Loading…
Reference in New Issue
Block a user