/src/trafficserver/tests/fuzzing/fuzz_http3frame.cc
Line | Count | Source |
1 | | /** @file |
2 | | |
3 | | fuzzing proxy/http3frame |
4 | | |
5 | | @section license License |
6 | | |
7 | | Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. |
8 | | See the NOTICE file distributed with this work for additional information regarding copyright |
9 | | ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the |
10 | | "License"); you may not use this file except in compliance with the License. You may obtain a |
11 | | copy of the License at |
12 | | |
13 | | http://www.apache.org/licenses/LICENSE-2.0 |
14 | | |
15 | | Unless required by applicable law or agreed to in writing, software distributed under the License |
16 | | is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
17 | | or implied. See the License for the specific language governing permissions and limitations under |
18 | | the License. |
19 | | */ |
20 | | |
21 | | #include "proxy/http3/Http3Frame.h" |
22 | | #include "proxy/http3/Http3Config.h" |
23 | | |
24 | | #include "records/RecordsConfig.h" |
25 | | #include "tscore/Layout.h" |
26 | | |
27 | 352 | #define kMinInputLength 8 |
28 | 172 | #define kMaxInputLength 1024 |
29 | | |
30 | 1 | #define TEST_THREADS 1 |
31 | | |
32 | | extern int cmd_disable_pfreelist; |
33 | | |
34 | | bool |
35 | | DoInitialization() |
36 | 1 | { |
37 | 1 | Layout::create(); |
38 | 1 | RecProcessInit(); |
39 | 1 | LibRecordsConfigInit(); |
40 | | |
41 | 1 | ink_event_system_init(EVENT_SYSTEM_MODULE_PUBLIC_VERSION); |
42 | 1 | eventProcessor.start(TEST_THREADS); |
43 | 1 | ts::Http3Config::startup(); |
44 | | |
45 | 1 | return true; |
46 | 1 | } |
47 | | |
48 | | extern "C" int |
49 | | LLVMFuzzerTestOneInput(const uint8_t *input_data, size_t size_data) |
50 | 176 | { |
51 | 176 | if (size_data < kMinInputLength || size_data > kMaxInputLength) { |
52 | 27 | return 1; |
53 | 27 | } |
54 | | |
55 | 149 | cmd_disable_pfreelist = true; |
56 | | |
57 | 149 | static bool Initialized = DoInitialization(); |
58 | | |
59 | 149 | MIOBuffer *input1 = new_MIOBuffer(BUFFER_SIZE_INDEX_128); |
60 | 149 | input1->write(input_data, size_data); |
61 | 149 | IOBufferReader *input_reader1 = input1->alloc_reader(); |
62 | | |
63 | 149 | Http3FrameFactory frame_factory; |
64 | 149 | frame_factory.fast_create(*input_reader1); |
65 | | |
66 | 149 | free_MIOBuffer(input1); |
67 | | |
68 | 149 | return 0; |
69 | 176 | } |