/src/trafficserver/tests/fuzzing/fuzz_proxy_protocol.cc
Line | Count | Source |
1 | | /** @file |
2 | | |
3 | | fuzzing iocore/net/ProxyProtocol |
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 "iocore/net/ProxyProtocol.h" |
22 | | #include "tscore/Diags.h" |
23 | | |
24 | 22.0k | #define kMinInputLength 8 |
25 | 11.0k | #define kMaxInputLength 1024 |
26 | | |
27 | | extern "C" int |
28 | | LLVMFuzzerTestOneInput(const uint8_t *input_data, size_t size_data) |
29 | 11.0k | { |
30 | 11.0k | if (size_data < kMinInputLength || size_data > kMaxInputLength) { |
31 | 110 | return 1; |
32 | 110 | } |
33 | | |
34 | 10.9k | swoc::TextView tv(reinterpret_cast<char *>((char *)input_data), size_data); |
35 | | |
36 | 10.9k | DiagsPtr::set(new Diags("fuzzing", "", "", nullptr)); |
37 | | |
38 | 10.9k | ProxyProtocol pp_info; |
39 | 10.9k | proxy_protocol_parse(&pp_info, tv); |
40 | | |
41 | 10.9k | delete diags(); |
42 | | |
43 | 10.9k | return 0; |
44 | 11.0k | } |