Limit input size for the rtp video layers allocation fuzzer
Bug: chromium:1355892 Change-Id: Ib0c48d27fb1e79212d2354e0249511aeeb53f650 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272961 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Per Kjellander <perkj@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37913}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
7643f373a0
commit
02c99982c8
@ -605,6 +605,10 @@ webrtc_fuzzer_test("rtp_video_layers_allocation_fuzzer") {
|
|||||||
"../../modules/rtp_rtcp:rtp_rtcp_format",
|
"../../modules/rtp_rtcp:rtp_rtcp_format",
|
||||||
"../../rtc_base:checks",
|
"../../rtc_base:checks",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# video_layers_allocation is an rtp header extension and thus can't be longer
|
||||||
|
# than 255 bytes on the wire.
|
||||||
|
libfuzzer_options = [ "max_len=255" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
webrtc_fuzzer_test("rtp_frame_reference_finder_fuzzer") {
|
webrtc_fuzzer_test("rtp_frame_reference_finder_fuzzer") {
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
#include "api/array_view.h"
|
#include "api/array_view.h"
|
||||||
#include "api/video/video_layers_allocation.h"
|
#include "api/video/video_layers_allocation.h"
|
||||||
@ -19,6 +20,14 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
void FuzzOneInput(const uint8_t* data, size_t size) {
|
void FuzzOneInput(const uint8_t* data, size_t size) {
|
||||||
|
// Video layers allocation is an rtp header extension.
|
||||||
|
// Per https://datatracker.ietf.org/doc/html/rfc8285#section-4.3
|
||||||
|
// rtp header extension uses up to one byte to store the size, i.e.
|
||||||
|
// maximum size of any rtp header extension is 255 bytes.
|
||||||
|
constexpr int kMaxSize = std::numeric_limits<uint8_t>::max();
|
||||||
|
if (size > kMaxSize) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto raw = rtc::MakeArrayView(data, size);
|
auto raw = rtc::MakeArrayView(data, size);
|
||||||
|
|
||||||
VideoLayersAllocation allocation1;
|
VideoLayersAllocation allocation1;
|
||||||
@ -32,10 +41,8 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
|
|||||||
// Check `writer` use minimal number of bytes to pack the extension by
|
// Check `writer` use minimal number of bytes to pack the extension by
|
||||||
// checking it doesn't use more than reader consumed.
|
// checking it doesn't use more than reader consumed.
|
||||||
RTC_CHECK_LE(value_size, raw.size());
|
RTC_CHECK_LE(value_size, raw.size());
|
||||||
uint8_t some_memory[256];
|
uint8_t some_memory[kMaxSize];
|
||||||
// An extension may not be larger than 255 bytes since the extension lenght
|
RTC_CHECK_LE(value_size, kMaxSize);
|
||||||
// field is only one byte.
|
|
||||||
RTC_CHECK_LT(value_size, 256);
|
|
||||||
rtc::ArrayView<uint8_t> write_buffer(some_memory, value_size);
|
rtc::ArrayView<uint8_t> write_buffer(some_memory, value_size);
|
||||||
RTC_CHECK(
|
RTC_CHECK(
|
||||||
RtpVideoLayersAllocationExtension::Write(write_buffer, allocation1));
|
RtpVideoLayersAllocationExtension::Write(write_buffer, allocation1));
|
||||||
|
Reference in New Issue
Block a user