Discard over large DataRates in VideoLayersAllocation rtp header extension

Bug: b/193170077
Change-Id: I427718daa70910dbaf7f2e1f3d88d3dce4f27c7a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226561
Reviewed-by: Emil Lundmark <lndmrk@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34520}
This commit is contained in:
Danil Chapovalov
2021-07-20 15:02:55 +00:00
committed by WebRTC LUCI CQ
parent 8c185fcabe
commit 6882a3f7d0
2 changed files with 12 additions and 2 deletions

View File

@ -354,10 +354,13 @@ bool RtpVideoLayersAllocationExtension::Parse(
// Target bitrates.
for (auto& layer : allocation->active_spatial_layers) {
for (DataRate& rate : layer.target_bitrate_per_temporal_layer) {
rate = DataRate::KilobitsPerSec(ReadLeb128(read_at, end));
if (read_at == nullptr) {
uint64_t bitrate_kbps = ReadLeb128(read_at, end);
// bitrate_kbps might represent larger values than DataRate type,
// discard unreasonably large values.
if (read_at == nullptr || bitrate_kbps > 1'000'000) {
return false;
}
rate = DataRate::KilobitsPerSec(bitrate_kbps);
}
}

View File

@ -249,5 +249,12 @@ TEST(RtpVideoLayersAllocationExtension,
RtpVideoLayersAllocationExtension::Write(buffer, written_allocation));
}
TEST(RtpVideoLayersAllocationExtension, DiscardsOverLargeDataRate) {
constexpr uint8_t buffer[] = {0x4b, 0xf6, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xcb, 0x78, 0xeb, 0x8d, 0xb5, 0x31};
VideoLayersAllocation allocation;
EXPECT_FALSE(RtpVideoLayersAllocationExtension::Parse(buffer, &allocation));
}
} // namespace
} // namespace webrtc