Coverage Report

Created: 2026-09-07 06:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/trafficserver/tests/fuzzing/fuzz_http.cc
Line
Count
Source
1
/** @file
2
3
  fuzzing proxy/hdrs & proxy/http
4
5
  @section license License
6
7
  Licensed to the Apache Software Foundation (ASF) under one
8
  or more contributor license agreements.  See the NOTICE file
9
  distributed with this work for additional information
10
  regarding copyright ownership.  The ASF licenses this file
11
  to you under the Apache License, Version 2.0 (the
12
  "License"); you may not use this file except in compliance
13
  with the License.  You may obtain a copy of the License at
14
15
      http://www.apache.org/licenses/LICENSE-2.0
16
17
  Unless required by applicable law or agreed to in writing, software
18
  distributed under the License is distributed on an "AS IS" BASIS,
19
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
  See the License for the specific language governing permissions and
21
  limitations under the License.
22
 */
23
24
#include "proxy/hdrs/HTTP.h"
25
#include "proxy/hdrs/HttpCompat.h"
26
#include "tscore/Diags.h"
27
28
25.4k
#define kMinInputLength 10
29
12.6k
#define kMaxInputLength 1024
30
31
extern int cmd_disable_pfreelist;
32
33
extern "C" int
34
LLVMFuzzerTestOneInput(const uint8_t *input_data, size_t size_data)
35
12.7k
{
36
12.7k
  if (size_data < kMinInputLength || size_data > kMaxInputLength) {
37
153
    return 0;
38
153
  }
39
40
12.5k
  std::string input(reinterpret_cast<const char *>(input_data), size_data);
41
12.5k
  char const *start = input.c_str();
42
12.5k
  char const *end   = input.c_str() + input.size();
43
44
12.5k
  cmd_disable_pfreelist = true;
45
12.5k
  DiagsPtr::set(new Diags("fuzzing", "", "", nullptr));
46
47
12.5k
  http_init();
48
49
12.5k
  HTTPParser parser;
50
12.5k
  HTTPHdr    req_hdr, rsp_hdr, req_hdr_2, rsp_hdr_2, req_hdr_3, rsp_hdr_3;
51
52
12.5k
  req_hdr.create(HTTPType::REQUEST);
53
12.5k
  rsp_hdr.create(HTTPType::RESPONSE);
54
12.5k
  req_hdr_2.create(HTTPType::REQUEST, HTTP_2_0);
55
12.5k
  rsp_hdr_2.create(HTTPType::RESPONSE, HTTP_2_0);
56
12.5k
  req_hdr_3.create(HTTPType::REQUEST, HTTP_3_0);
57
12.5k
  rsp_hdr_3.create(HTTPType::RESPONSE, HTTP_3_0);
58
59
12.5k
  {
60
12.5k
    http_parser_init(&parser);
61
12.5k
    ParseResult result = req_hdr.parse_req(&parser, &start, end, true);
62
12.5k
    http_parser_clear(&parser);
63
12.5k
  }
64
12.5k
  {
65
12.5k
    http_parser_init(&parser);
66
12.5k
    ParseResult result = rsp_hdr.parse_resp(&parser, &start, end, true);
67
12.5k
    http_parser_clear(&parser);
68
12.5k
  }
69
12.5k
  {
70
12.5k
    http_parser_init(&parser);
71
12.5k
    ParseResult result = req_hdr_2.parse_req(&parser, &start, end, true);
72
12.5k
    http_parser_clear(&parser);
73
12.5k
  }
74
12.5k
  {
75
12.5k
    http_parser_init(&parser);
76
12.5k
    ParseResult result = rsp_hdr_2.parse_resp(&parser, &start, end, true);
77
12.5k
    http_parser_clear(&parser);
78
12.5k
  }
79
12.5k
  {
80
12.5k
    http_parser_init(&parser);
81
12.5k
    ParseResult result = req_hdr_3.parse_req(&parser, &start, end, true);
82
12.5k
    http_parser_clear(&parser);
83
12.5k
  }
84
12.5k
  {
85
12.5k
    http_parser_init(&parser);
86
12.5k
    ParseResult result = rsp_hdr_3.parse_resp(&parser, &start, end, true);
87
12.5k
    http_parser_clear(&parser);
88
12.5k
  }
89
90
12.5k
  req_hdr.destroy();
91
12.5k
  rsp_hdr.destroy();
92
12.5k
  req_hdr_2.destroy();
93
12.5k
  rsp_hdr_2.destroy();
94
12.5k
  req_hdr_3.destroy();
95
12.5k
  rsp_hdr_3.destroy();
96
97
12.5k
  delete diags();
98
99
12.5k
  return 0;
100
12.7k
}