From 90c3981773d0f058ec7f42c871533254c24c3429 Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Wed, 24 Mar 2021 13:10:08 +0100 Subject: [PATCH] Fix RtpVideoLayersAllocationExtension::Write of invalid allocation This patch is a follow up to https://webrtc-review.googlesource.com/c/src/+/212743 which broke downstream fuzzer :( prior to https://webrtc-review.googlesource.com/c/src/+/212743, RtpVideoLayersAllocationExtension::AllocationIsValid returns false if rtp_stream_index > max(layer.rtp_stream_index) After https://webrtc-review.googlesource.com/c/src/+/212743, 0 spatial layers is supported, so the AllocationIsValid is updated to allow any value if not layers are present. Bug: webrtc:12000 Change-Id: Ib3e64ecb621f795b9126442c50969f5178c85a37 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/212901 Commit-Queue: Jonas Oreland Reviewed-by: Danil Chapovalov Cr-Commit-Position: refs/heads/master@{#33551} --- .../source/rtp_video_layers_allocation_extension.cc | 3 ++- .../rtp_video_layers_allocation_extension_unittest.cc | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/rtp_rtcp/source/rtp_video_layers_allocation_extension.cc b/modules/rtp_rtcp/source/rtp_video_layers_allocation_extension.cc index 23b2f3b8a1..be6aadb084 100644 --- a/modules/rtp_rtcp/source/rtp_video_layers_allocation_extension.cc +++ b/modules/rtp_rtcp/source/rtp_video_layers_allocation_extension.cc @@ -117,7 +117,8 @@ bool AllocationIsValid(const VideoLayersAllocation& allocation) { } } if (allocation.rtp_stream_index < 0 || - allocation.rtp_stream_index > max_rtp_stream_idx) { + (!allocation.active_spatial_layers.empty() && + allocation.rtp_stream_index > max_rtp_stream_idx)) { return false; } return true; diff --git a/modules/rtp_rtcp/source/rtp_video_layers_allocation_extension_unittest.cc b/modules/rtp_rtcp/source/rtp_video_layers_allocation_extension_unittest.cc index 23a7961ce8..92e5673441 100644 --- a/modules/rtp_rtcp/source/rtp_video_layers_allocation_extension_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_video_layers_allocation_extension_unittest.cc @@ -239,5 +239,15 @@ TEST(RtpVideoLayersAllocationExtension, EXPECT_EQ(written_allocation, parsed_allocation); } +TEST(RtpVideoLayersAllocationExtension, + WriteEmptyAllocationCanHaveAnyRtpStreamIndex) { + VideoLayersAllocation written_allocation; + written_allocation.rtp_stream_index = 1; + rtc::Buffer buffer( + RtpVideoLayersAllocationExtension::ValueSize(written_allocation)); + EXPECT_TRUE( + RtpVideoLayersAllocationExtension::Write(buffer, written_allocation)); +} + } // namespace } // namespace webrtc