diff options
Diffstat (limited to 'third_party/libwebrtc/test/fuzzers')
6 files changed, 246 insertions, 222 deletions
diff --git a/third_party/libwebrtc/test/fuzzers/BUILD.gn b/third_party/libwebrtc/test/fuzzers/BUILD.gn index 083c20c6f4..642b0c8e08 100644 --- a/third_party/libwebrtc/test/fuzzers/BUILD.gn +++ b/third_party/libwebrtc/test/fuzzers/BUILD.gn @@ -132,6 +132,11 @@ if (rtc_use_h265) { "../../modules/video_coding/", ] } + + webrtc_fuzzer_test("h265_depacketizer_fuzzer") { + sources = [ "h265_depacketizer_fuzzer.cc" ] + deps = [ "../../modules/rtp_rtcp" ] + } } webrtc_fuzzer_test("forward_error_correction_fuzzer") { @@ -471,6 +476,7 @@ webrtc_fuzzer_test("stun_validator_fuzzer") { webrtc_fuzzer_test("pseudotcp_parser_fuzzer") { sources = [ "pseudotcp_parser_fuzzer.cc" ] deps = [ + "../../p2p:pseudo_tcp", "../../p2p:rtc_p2p", "../../rtc_base:threading", ] diff --git a/third_party/libwebrtc/test/fuzzers/h265_depacketizer_fuzzer.cc b/third_party/libwebrtc/test/fuzzers/h265_depacketizer_fuzzer.cc new file mode 100644 index 0000000000..00025ef887 --- /dev/null +++ b/third_party/libwebrtc/test/fuzzers/h265_depacketizer_fuzzer.cc @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#include "modules/rtp_rtcp/source/video_rtp_depacketizer_h265.h" + +namespace webrtc { +void FuzzOneInput(const uint8_t* data, size_t size) { + if (size > 200000) + return; + VideoRtpDepacketizerH265 depacketizer; + depacketizer.Parse(rtc::CopyOnWriteBuffer(data, size)); +} +} // namespace webrtc diff --git a/third_party/libwebrtc/test/fuzzers/neteq_signal_fuzzer.cc b/third_party/libwebrtc/test/fuzzers/neteq_signal_fuzzer.cc index 485c38085e..3b1f70cdb4 100644 --- a/third_party/libwebrtc/test/fuzzers/neteq_signal_fuzzer.cc +++ b/third_party/libwebrtc/test/fuzzers/neteq_signal_fuzzer.cc @@ -179,7 +179,6 @@ void FuzzOneInputTest(const uint8_t* data, size_t size) { // Configure NetEq and the NetEqTest object. NetEqTest::Callbacks callbacks; NetEq::Config config; - config.enable_post_decode_vad = true; config.enable_fast_accelerate = true; auto codecs = NetEqTest::StandardDecoderMap(); // rate_types contains the payload types that will be used for encoding. diff --git a/third_party/libwebrtc/test/fuzzers/rtp_format_h264_fuzzer.cc b/third_party/libwebrtc/test/fuzzers/rtp_format_h264_fuzzer.cc index ddf2ca9d3d..97b0ce2c03 100644 --- a/third_party/libwebrtc/test/fuzzers/rtp_format_h264_fuzzer.cc +++ b/third_party/libwebrtc/test/fuzzers/rtp_format_h264_fuzzer.cc @@ -1,75 +1,75 @@ -/*
- * Copyright (c) 2024 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-#include <stddef.h>
-#include <stdint.h>
-
-#include "api/video/video_frame_type.h"
-#include "modules/rtp_rtcp/source/rtp_format.h"
-#include "modules/rtp_rtcp/source/rtp_format_h264.h"
-#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
-#include "rtc_base/checks.h"
-#include "test/fuzzers/fuzz_data_helper.h"
-
-namespace webrtc {
-void FuzzOneInput(const uint8_t* data, size_t size) {
- test::FuzzDataHelper fuzz_input(rtc::MakeArrayView(data, size));
-
- RtpPacketizer::PayloadSizeLimits limits;
- limits.max_payload_len = 1200;
- // Read uint8_t to be sure reduction_lens are much smaller than
- // max_payload_len and thus limits structure is valid.
- limits.first_packet_reduction_len = fuzz_input.ReadOrDefaultValue<uint8_t>(0);
- limits.last_packet_reduction_len = fuzz_input.ReadOrDefaultValue<uint8_t>(0);
- limits.single_packet_reduction_len =
- fuzz_input.ReadOrDefaultValue<uint8_t>(0);
- const H264PacketizationMode kPacketizationModes[] = {
- H264PacketizationMode::NonInterleaved,
- H264PacketizationMode::SingleNalUnit};
-
- H264PacketizationMode packetization_mode =
- fuzz_input.SelectOneOf(kPacketizationModes);
-
- // Main function under test: RtpPacketizerH264's constructor.
- RtpPacketizerH264 packetizer(fuzz_input.ReadByteArray(fuzz_input.BytesLeft()),
- limits, packetization_mode);
-
- size_t num_packets = packetizer.NumPackets();
- if (num_packets == 0) {
- return;
- }
- // When packetization was successful, validate NextPacket function too.
- // While at it, check that packets respect the payload size limits.
- RtpPacketToSend rtp_packet(nullptr);
- // Single packet.
- if (num_packets == 1) {
- RTC_CHECK(packetizer.NextPacket(&rtp_packet));
- RTC_CHECK_LE(rtp_packet.payload_size(),
- limits.max_payload_len - limits.single_packet_reduction_len);
- return;
- }
- // First packet.
- RTC_CHECK(packetizer.NextPacket(&rtp_packet));
- RTC_CHECK_LE(rtp_packet.payload_size(),
- limits.max_payload_len - limits.first_packet_reduction_len);
- // Middle packets.
- for (size_t i = 1; i < num_packets - 1; ++i) {
- rtp_packet.Clear();
- RTC_CHECK(packetizer.NextPacket(&rtp_packet))
- << "Failed to get packet#" << i;
- RTC_CHECK_LE(rtp_packet.payload_size(), limits.max_payload_len)
- << "Packet #" << i << " exceeds it's limit";
- }
- // Last packet.
- rtp_packet.Clear();
- RTC_CHECK(packetizer.NextPacket(&rtp_packet));
- RTC_CHECK_LE(rtp_packet.payload_size(),
- limits.max_payload_len - limits.last_packet_reduction_len);
-}
-} // namespace webrtc
+/* + * Copyright (c) 2024 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#include <stddef.h> +#include <stdint.h> + +#include "api/video/video_frame_type.h" +#include "modules/rtp_rtcp/source/rtp_format.h" +#include "modules/rtp_rtcp/source/rtp_format_h264.h" +#include "modules/rtp_rtcp/source/rtp_packet_to_send.h" +#include "rtc_base/checks.h" +#include "test/fuzzers/fuzz_data_helper.h" + +namespace webrtc { +void FuzzOneInput(const uint8_t* data, size_t size) { + test::FuzzDataHelper fuzz_input(rtc::MakeArrayView(data, size)); + + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 1200; + // Read uint8_t to be sure reduction_lens are much smaller than + // max_payload_len and thus limits structure is valid. + limits.first_packet_reduction_len = fuzz_input.ReadOrDefaultValue<uint8_t>(0); + limits.last_packet_reduction_len = fuzz_input.ReadOrDefaultValue<uint8_t>(0); + limits.single_packet_reduction_len = + fuzz_input.ReadOrDefaultValue<uint8_t>(0); + const H264PacketizationMode kPacketizationModes[] = { + H264PacketizationMode::NonInterleaved, + H264PacketizationMode::SingleNalUnit}; + + H264PacketizationMode packetization_mode = + fuzz_input.SelectOneOf(kPacketizationModes); + + // Main function under test: RtpPacketizerH264's constructor. + RtpPacketizerH264 packetizer(fuzz_input.ReadByteArray(fuzz_input.BytesLeft()), + limits, packetization_mode); + + size_t num_packets = packetizer.NumPackets(); + if (num_packets == 0) { + return; + } + // When packetization was successful, validate NextPacket function too. + // While at it, check that packets respect the payload size limits. + RtpPacketToSend rtp_packet(nullptr); + // Single packet. + if (num_packets == 1) { + RTC_CHECK(packetizer.NextPacket(&rtp_packet)); + RTC_CHECK_LE(rtp_packet.payload_size(), + limits.max_payload_len - limits.single_packet_reduction_len); + return; + } + // First packet. + RTC_CHECK(packetizer.NextPacket(&rtp_packet)); + RTC_CHECK_LE(rtp_packet.payload_size(), + limits.max_payload_len - limits.first_packet_reduction_len); + // Middle packets. + for (size_t i = 1; i < num_packets - 1; ++i) { + rtp_packet.Clear(); + RTC_CHECK(packetizer.NextPacket(&rtp_packet)) + << "Failed to get packet#" << i; + RTC_CHECK_LE(rtp_packet.payload_size(), limits.max_payload_len) + << "Packet #" << i << " exceeds it's limit"; + } + // Last packet. + rtp_packet.Clear(); + RTC_CHECK(packetizer.NextPacket(&rtp_packet)); + RTC_CHECK_LE(rtp_packet.payload_size(), + limits.max_payload_len - limits.last_packet_reduction_len); +} +} // namespace webrtc diff --git a/third_party/libwebrtc/test/fuzzers/rtp_format_vp8_fuzzer.cc b/third_party/libwebrtc/test/fuzzers/rtp_format_vp8_fuzzer.cc index c3c055de0f..93706e9253 100644 --- a/third_party/libwebrtc/test/fuzzers/rtp_format_vp8_fuzzer.cc +++ b/third_party/libwebrtc/test/fuzzers/rtp_format_vp8_fuzzer.cc @@ -1,73 +1,73 @@ -/*
- * Copyright (c) 2024 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-#include <stddef.h>
-#include <stdint.h>
-
-#include "api/video/video_frame_type.h"
-#include "modules/rtp_rtcp/source/rtp_format.h"
-#include "modules/rtp_rtcp/source/rtp_format_vp8.h"
-#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
-#include "rtc_base/checks.h"
-#include "test/fuzzers/fuzz_data_helper.h"
-
-namespace webrtc {
-void FuzzOneInput(const uint8_t* data, size_t size) {
- test::FuzzDataHelper fuzz_input(rtc::MakeArrayView(data, size));
-
- RtpPacketizer::PayloadSizeLimits limits;
- limits.max_payload_len = 1200;
- // Read uint8_t to be sure reduction_lens are much smaller than
- // max_payload_len and thus limits structure is valid.
- limits.first_packet_reduction_len = fuzz_input.ReadOrDefaultValue<uint8_t>(0);
- limits.last_packet_reduction_len = fuzz_input.ReadOrDefaultValue<uint8_t>(0);
- limits.single_packet_reduction_len =
- fuzz_input.ReadOrDefaultValue<uint8_t>(0);
-
- RTPVideoHeaderVP8 hdr_info;
- hdr_info.InitRTPVideoHeaderVP8();
- uint16_t picture_id = fuzz_input.ReadOrDefaultValue<uint16_t>(0);
- hdr_info.pictureId =
- picture_id >= 0x8000 ? kNoPictureId : picture_id & 0x7fff;
-
- // Main function under test: RtpPacketizerVp8's constructor.
- RtpPacketizerVp8 packetizer(fuzz_input.ReadByteArray(fuzz_input.BytesLeft()),
- limits, hdr_info);
-
- size_t num_packets = packetizer.NumPackets();
- if (num_packets == 0) {
- return;
- }
- // When packetization was successful, validate NextPacket function too.
- // While at it, check that packets respect the payload size limits.
- RtpPacketToSend rtp_packet(nullptr);
- // Single packet.
- if (num_packets == 1) {
- RTC_CHECK(packetizer.NextPacket(&rtp_packet));
- RTC_CHECK_LE(rtp_packet.payload_size(),
- limits.max_payload_len - limits.single_packet_reduction_len);
- return;
- }
- // First packet.
- RTC_CHECK(packetizer.NextPacket(&rtp_packet));
- RTC_CHECK_LE(rtp_packet.payload_size(),
- limits.max_payload_len - limits.first_packet_reduction_len);
- // Middle packets.
- for (size_t i = 1; i < num_packets - 1; ++i) {
- RTC_CHECK(packetizer.NextPacket(&rtp_packet))
- << "Failed to get packet#" << i;
- RTC_CHECK_LE(rtp_packet.payload_size(), limits.max_payload_len)
- << "Packet #" << i << " exceeds it's limit";
- }
- // Last packet.
- RTC_CHECK(packetizer.NextPacket(&rtp_packet));
- RTC_CHECK_LE(rtp_packet.payload_size(),
- limits.max_payload_len - limits.last_packet_reduction_len);
-}
-} // namespace webrtc
+/* + * Copyright (c) 2024 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#include <stddef.h> +#include <stdint.h> + +#include "api/video/video_frame_type.h" +#include "modules/rtp_rtcp/source/rtp_format.h" +#include "modules/rtp_rtcp/source/rtp_format_vp8.h" +#include "modules/rtp_rtcp/source/rtp_packet_to_send.h" +#include "rtc_base/checks.h" +#include "test/fuzzers/fuzz_data_helper.h" + +namespace webrtc { +void FuzzOneInput(const uint8_t* data, size_t size) { + test::FuzzDataHelper fuzz_input(rtc::MakeArrayView(data, size)); + + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 1200; + // Read uint8_t to be sure reduction_lens are much smaller than + // max_payload_len and thus limits structure is valid. + limits.first_packet_reduction_len = fuzz_input.ReadOrDefaultValue<uint8_t>(0); + limits.last_packet_reduction_len = fuzz_input.ReadOrDefaultValue<uint8_t>(0); + limits.single_packet_reduction_len = + fuzz_input.ReadOrDefaultValue<uint8_t>(0); + + RTPVideoHeaderVP8 hdr_info; + hdr_info.InitRTPVideoHeaderVP8(); + uint16_t picture_id = fuzz_input.ReadOrDefaultValue<uint16_t>(0); + hdr_info.pictureId = + picture_id >= 0x8000 ? kNoPictureId : picture_id & 0x7fff; + + // Main function under test: RtpPacketizerVp8's constructor. + RtpPacketizerVp8 packetizer(fuzz_input.ReadByteArray(fuzz_input.BytesLeft()), + limits, hdr_info); + + size_t num_packets = packetizer.NumPackets(); + if (num_packets == 0) { + return; + } + // When packetization was successful, validate NextPacket function too. + // While at it, check that packets respect the payload size limits. + RtpPacketToSend rtp_packet(nullptr); + // Single packet. + if (num_packets == 1) { + RTC_CHECK(packetizer.NextPacket(&rtp_packet)); + RTC_CHECK_LE(rtp_packet.payload_size(), + limits.max_payload_len - limits.single_packet_reduction_len); + return; + } + // First packet. + RTC_CHECK(packetizer.NextPacket(&rtp_packet)); + RTC_CHECK_LE(rtp_packet.payload_size(), + limits.max_payload_len - limits.first_packet_reduction_len); + // Middle packets. + for (size_t i = 1; i < num_packets - 1; ++i) { + RTC_CHECK(packetizer.NextPacket(&rtp_packet)) + << "Failed to get packet#" << i; + RTC_CHECK_LE(rtp_packet.payload_size(), limits.max_payload_len) + << "Packet #" << i << " exceeds it's limit"; + } + // Last packet. + RTC_CHECK(packetizer.NextPacket(&rtp_packet)); + RTC_CHECK_LE(rtp_packet.payload_size(), + limits.max_payload_len - limits.last_packet_reduction_len); +} +} // namespace webrtc diff --git a/third_party/libwebrtc/test/fuzzers/rtp_format_vp9_fuzzer.cc b/third_party/libwebrtc/test/fuzzers/rtp_format_vp9_fuzzer.cc index 3b5e67f697..d95114eaef 100644 --- a/third_party/libwebrtc/test/fuzzers/rtp_format_vp9_fuzzer.cc +++ b/third_party/libwebrtc/test/fuzzers/rtp_format_vp9_fuzzer.cc @@ -1,73 +1,73 @@ -/*
- * Copyright (c) 2024 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-#include <stddef.h>
-#include <stdint.h>
-
-#include "api/video/video_frame_type.h"
-#include "modules/rtp_rtcp/source/rtp_format.h"
-#include "modules/rtp_rtcp/source/rtp_format_vp9.h"
-#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
-#include "rtc_base/checks.h"
-#include "test/fuzzers/fuzz_data_helper.h"
-
-namespace webrtc {
-void FuzzOneInput(const uint8_t* data, size_t size) {
- test::FuzzDataHelper fuzz_input(rtc::MakeArrayView(data, size));
-
- RtpPacketizer::PayloadSizeLimits limits;
- limits.max_payload_len = 1200;
- // Read uint8_t to be sure reduction_lens are much smaller than
- // max_payload_len and thus limits structure is valid.
- limits.first_packet_reduction_len = fuzz_input.ReadOrDefaultValue<uint8_t>(0);
- limits.last_packet_reduction_len = fuzz_input.ReadOrDefaultValue<uint8_t>(0);
- limits.single_packet_reduction_len =
- fuzz_input.ReadOrDefaultValue<uint8_t>(0);
-
- RTPVideoHeaderVP9 hdr_info;
- hdr_info.InitRTPVideoHeaderVP9();
- uint16_t picture_id = fuzz_input.ReadOrDefaultValue<uint16_t>(0);
- hdr_info.picture_id =
- picture_id >= 0x8000 ? kNoPictureId : picture_id & 0x7fff;
-
- // Main function under test: RtpPacketizerVp9's constructor.
- RtpPacketizerVp9 packetizer(fuzz_input.ReadByteArray(fuzz_input.BytesLeft()),
- limits, hdr_info);
-
- size_t num_packets = packetizer.NumPackets();
- if (num_packets == 0) {
- return;
- }
- // When packetization was successful, validate NextPacket function too.
- // While at it, check that packets respect the payload size limits.
- RtpPacketToSend rtp_packet(nullptr);
- // Single packet.
- if (num_packets == 1) {
- RTC_CHECK(packetizer.NextPacket(&rtp_packet));
- RTC_CHECK_LE(rtp_packet.payload_size(),
- limits.max_payload_len - limits.single_packet_reduction_len);
- return;
- }
- // First packet.
- RTC_CHECK(packetizer.NextPacket(&rtp_packet));
- RTC_CHECK_LE(rtp_packet.payload_size(),
- limits.max_payload_len - limits.first_packet_reduction_len);
- // Middle packets.
- for (size_t i = 1; i < num_packets - 1; ++i) {
- RTC_CHECK(packetizer.NextPacket(&rtp_packet))
- << "Failed to get packet#" << i;
- RTC_CHECK_LE(rtp_packet.payload_size(), limits.max_payload_len)
- << "Packet #" << i << " exceeds it's limit";
- }
- // Last packet.
- RTC_CHECK(packetizer.NextPacket(&rtp_packet));
- RTC_CHECK_LE(rtp_packet.payload_size(),
- limits.max_payload_len - limits.last_packet_reduction_len);
-}
-} // namespace webrtc
+/* + * Copyright (c) 2024 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#include <stddef.h> +#include <stdint.h> + +#include "api/video/video_frame_type.h" +#include "modules/rtp_rtcp/source/rtp_format.h" +#include "modules/rtp_rtcp/source/rtp_format_vp9.h" +#include "modules/rtp_rtcp/source/rtp_packet_to_send.h" +#include "rtc_base/checks.h" +#include "test/fuzzers/fuzz_data_helper.h" + +namespace webrtc { +void FuzzOneInput(const uint8_t* data, size_t size) { + test::FuzzDataHelper fuzz_input(rtc::MakeArrayView(data, size)); + + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 1200; + // Read uint8_t to be sure reduction_lens are much smaller than + // max_payload_len and thus limits structure is valid. + limits.first_packet_reduction_len = fuzz_input.ReadOrDefaultValue<uint8_t>(0); + limits.last_packet_reduction_len = fuzz_input.ReadOrDefaultValue<uint8_t>(0); + limits.single_packet_reduction_len = + fuzz_input.ReadOrDefaultValue<uint8_t>(0); + + RTPVideoHeaderVP9 hdr_info; + hdr_info.InitRTPVideoHeaderVP9(); + uint16_t picture_id = fuzz_input.ReadOrDefaultValue<uint16_t>(0); + hdr_info.picture_id = + picture_id >= 0x8000 ? kNoPictureId : picture_id & 0x7fff; + + // Main function under test: RtpPacketizerVp9's constructor. + RtpPacketizerVp9 packetizer(fuzz_input.ReadByteArray(fuzz_input.BytesLeft()), + limits, hdr_info); + + size_t num_packets = packetizer.NumPackets(); + if (num_packets == 0) { + return; + } + // When packetization was successful, validate NextPacket function too. + // While at it, check that packets respect the payload size limits. + RtpPacketToSend rtp_packet(nullptr); + // Single packet. + if (num_packets == 1) { + RTC_CHECK(packetizer.NextPacket(&rtp_packet)); + RTC_CHECK_LE(rtp_packet.payload_size(), + limits.max_payload_len - limits.single_packet_reduction_len); + return; + } + // First packet. + RTC_CHECK(packetizer.NextPacket(&rtp_packet)); + RTC_CHECK_LE(rtp_packet.payload_size(), + limits.max_payload_len - limits.first_packet_reduction_len); + // Middle packets. + for (size_t i = 1; i < num_packets - 1; ++i) { + RTC_CHECK(packetizer.NextPacket(&rtp_packet)) + << "Failed to get packet#" << i; + RTC_CHECK_LE(rtp_packet.payload_size(), limits.max_payload_len) + << "Packet #" << i << " exceeds it's limit"; + } + // Last packet. + RTC_CHECK(packetizer.NextPacket(&rtp_packet)); + RTC_CHECK_LE(rtp_packet.payload_size(), + limits.max_payload_len - limits.last_packet_reduction_len); +} +} // namespace webrtc |