xref: /aosp_15_r20/external/webrtc/net/dcsctp/fuzzers/dcsctp_fuzzers_test.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/fuzzers/dcsctp_fuzzers.h"
11 
12 #include "api/array_view.h"
13 #include "net/dcsctp/packet/sctp_packet.h"
14 #include "net/dcsctp/public/dcsctp_socket.h"
15 #include "net/dcsctp/socket/dcsctp_socket.h"
16 #include "net/dcsctp/testing/testing_macros.h"
17 #include "rtc_base/gunit.h"
18 #include "rtc_base/logging.h"
19 #include "test/gmock.h"
20 
21 namespace dcsctp {
22 namespace dcsctp_fuzzers {
23 namespace {
24 
25 // This is a testbed where fuzzed data that cause issues can be evaluated and
26 // crashes reproduced. Use `xxd -i ./crash-abc` to generate `data` below.
TEST(DcsctpFuzzersTest,PassesTestbed)27 TEST(DcsctpFuzzersTest, PassesTestbed) {
28   uint8_t data[] = {0x07, 0x09, 0x00, 0x01, 0x11, 0xff, 0xff};
29 
30   FuzzerCallbacks cb;
31   DcSctpOptions options;
32   options.disable_checksum_verification = true;
33   DcSctpSocket socket("A", cb, nullptr, options);
34 
35   FuzzSocket(socket, cb, data);
36 }
37 
38 }  // namespace
39 }  // namespace dcsctp_fuzzers
40 }  // namespace dcsctp
41