1 /* 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include <memory> 12 #include <utility> 13 14 #include "modules/video_coding/frame_object.h" 15 #include "modules/video_coding/packet_buffer.h" 16 #include "system_wrappers/include/clock.h" 17 #include "test/fuzzers/fuzz_data_helper.h" 18 19 namespace webrtc { 20 IgnoreResult(video_coding::PacketBuffer::InsertResult result)21void IgnoreResult(video_coding::PacketBuffer::InsertResult result) {} 22 FuzzOneInput(const uint8_t * data,size_t size)23void FuzzOneInput(const uint8_t* data, size_t size) { 24 if (size > 200000) { 25 return; 26 } 27 SimulatedClock clock(0); 28 video_coding::PacketBuffer packet_buffer(&clock, 8, 1024); 29 test::FuzzDataHelper helper(rtc::ArrayView<const uint8_t>(data, size)); 30 31 while (helper.BytesLeft()) { 32 auto packet = std::make_unique<video_coding::PacketBuffer::Packet>(); 33 // Fuzz POD members of the packet. 34 helper.CopyTo(&packet->marker_bit); 35 helper.CopyTo(&packet->payload_type); 36 helper.CopyTo(&packet->seq_num); 37 helper.CopyTo(&packet->timestamp); 38 helper.CopyTo(&packet->ntp_time_ms); 39 helper.CopyTo(&packet->times_nacked); 40 41 // Fuzz non-POD member of the packet. 42 packet->video_payload.SetSize(helper.ReadOrDefaultValue<uint8_t>(0)); 43 // TODO(danilchap): Fuzz other non-POD members of the |packet|. 44 45 IgnoreResult(packet_buffer.InsertPacket(std::move(packet))); 46 } 47 } 48 49 } // namespace webrtc 50