• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2019 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 #include "modules/rtp_rtcp/source/video_rtp_depacketizer_av1.h"
11 
12 #include <stddef.h>
13 #include <stdint.h>
14 
15 #include <vector>
16 
17 #include "api/array_view.h"
18 #include "test/fuzzers/fuzz_data_helper.h"
19 
20 namespace webrtc {
FuzzOneInput(const uint8_t * data,size_t size)21 void FuzzOneInput(const uint8_t* data, size_t size) {
22   std::vector<rtc::ArrayView<const uint8_t>> rtp_payloads;
23 
24   // Convert plain array of bytes into array of array bytes.
25   test::FuzzDataHelper fuzz_input(rtc::MakeArrayView(data, size));
26   while (fuzz_input.CanReadBytes(sizeof(uint16_t))) {
27     // In practice one rtp payload can be up to ~1200 - 1500 bytes. Majority
28     // of the payload is just copied. To make fuzzing more efficient limit the
29     // size of rtp payload to realistic value.
30     uint16_t next_size = fuzz_input.Read<uint16_t>() % 1200;
31     if (next_size > fuzz_input.BytesLeft()) {
32       next_size = fuzz_input.BytesLeft();
33     }
34     rtp_payloads.push_back(fuzz_input.ReadByteArray(next_size));
35   }
36   // Run code under test.
37   VideoRtpDepacketizerAv1().AssembleFrame(rtp_payloads);
38 }
39 }  // namespace webrtc
40