2017-01-11 02:01:56 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2017 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-01-24 16:04:35 +01:00
|
|
|
#include <memory>
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
2018-10-05 10:38:13 -07:00
|
|
|
#include "modules/video_coding/frame_object.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/video_coding/packet_buffer.h"
|
2018-05-17 16:44:47 +02:00
|
|
|
#include "test/fuzzers/fuzz_data_helper.h"
|
2017-01-11 02:01:56 -08:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2019-10-22 17:12:42 +02:00
|
|
|
|
|
|
|
|
void IgnoreResult(video_coding::PacketBuffer::InsertResult result) {}
|
2017-01-11 02:01:56 -08:00
|
|
|
|
|
|
|
|
void FuzzOneInput(const uint8_t* data, size_t size) {
|
2018-10-25 13:46:26 +02:00
|
|
|
if (size > 200000) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-12 13:42:03 +02:00
|
|
|
video_coding::PacketBuffer packet_buffer(8, 1024);
|
2018-05-17 16:44:47 +02:00
|
|
|
test::FuzzDataHelper helper(rtc::ArrayView<const uint8_t>(data, size));
|
2017-01-11 02:01:56 -08:00
|
|
|
|
2018-07-10 11:31:29 +02:00
|
|
|
while (helper.BytesLeft()) {
|
2020-01-24 16:04:35 +01:00
|
|
|
auto packet = std::make_unique<video_coding::PacketBuffer::Packet>();
|
2019-12-02 15:54:27 +01:00
|
|
|
// Fuzz POD members of the packet.
|
2020-01-24 16:04:35 +01:00
|
|
|
helper.CopyTo(&packet->marker_bit);
|
|
|
|
|
helper.CopyTo(&packet->payload_type);
|
|
|
|
|
helper.CopyTo(&packet->seq_num);
|
|
|
|
|
helper.CopyTo(&packet->timestamp);
|
|
|
|
|
helper.CopyTo(&packet->times_nacked);
|
2019-12-02 15:54:27 +01:00
|
|
|
|
|
|
|
|
// Fuzz non-POD member of the packet.
|
2020-01-24 16:04:35 +01:00
|
|
|
packet->video_payload.SetSize(helper.ReadOrDefaultValue<uint8_t>(0));
|
2021-07-27 12:46:29 +02:00
|
|
|
// TODO(danilchap): Fuzz other non-POD members of the `packet`.
|
2018-07-10 11:31:29 +02:00
|
|
|
|
2020-01-24 16:04:35 +01:00
|
|
|
IgnoreResult(packet_buffer.InsertPacket(std::move(packet)));
|
2018-07-10 11:31:29 +02:00
|
|
|
}
|
2017-01-11 02:01:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|