xref: /aosp_15_r20/external/webrtc/test/fuzzers/dcsctp_packet_fuzzer.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2021 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 "net/dcsctp/packet/chunk/chunk.h"
11 #include "net/dcsctp/packet/sctp_packet.h"
12 
13 namespace webrtc {
14 using dcsctp::SctpPacket;
15 
FuzzOneInput(const uint8_t * data,size_t size)16 void FuzzOneInput(const uint8_t* data, size_t size) {
17   absl::optional<SctpPacket> c =
18       SctpPacket::Parse(rtc::ArrayView<const uint8_t>(data, size),
19                         /*disable_checksum_verification=*/true);
20 
21   if (!c.has_value()) {
22     return;
23   }
24 
25   for (const SctpPacket::ChunkDescriptor& desc : c->descriptors()) {
26     dcsctp::DebugConvertChunkToString(desc.data);
27   }
28 }
29 }  // namespace webrtc
30