Coverage Report

Created: 2026-10-31 06:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/curl_fuzzer/proto_fuzzer/option_apply.h
Line
Count
Source
1
/*
2
 * Copyright (C) Max Dymond, <cmeister2@gmail.com>, et al.
3
 *
4
 * SPDX-License-Identifier: curl
5
 */
6
7
/// @file
8
/// @brief Translates Scenario SetOption messages into curl_easy_setopt calls,
9
///        plus the fixed baseline setopts the harness always applies.
10
11
#ifndef PROTO_FUZZER_OPTION_APPLY_H_
12
#define PROTO_FUZZER_OPTION_APPLY_H_
13
14
#include <curl/curl.h>
15
16
#include <cstddef>
17
#include <cstdint>
18
#include <string>
19
20
#include "curl_fuzzer.pb.h"
21
#include "proto_fuzzer/curl_raii.h"
22
#include "proto_fuzzer/option_model.h"
23
24
namespace proto_fuzzer {
25
26
/// Reset curl's global trace configuration to a known off baseline for the
27
/// lifetime of one input.
28
///
29
/// curl_global_trace() only mutates the components it names and exposes no
30
/// read-back, so a true save/restore is not possible through the public API.
31
/// Instead the guard resets "-all" on both entry and exit: the input's trace
32
/// selection is contained to the guard's scope, and a previous input's "all"
33
/// (or any subset it left enabled) cannot leak into the next input. This makes
34
/// coverage and any trace-dependent failure independent of corpus order.
35
class ScopedTraceReset final {
36
 public:
37
332k
  ScopedTraceReset() { (void)curl_global_trace("-all"); }
38
332k
  ~ScopedTraceReset() { (void)curl_global_trace("-all"); }
39
40
  ScopedTraceReset(const ScopedTraceReset&) = delete;
41
  ScopedTraceReset& operator=(const ScopedTraceReset&) = delete;
42
  ScopedTraceReset(ScopedTraceReset&&) = delete;
43
  ScopedTraceReset& operator=(ScopedTraceReset&&) = delete;
44
};
45
46
CurlSlistPtr ApplyBaselineOptions(CURL* easy, curl::fuzzer::proto::Scheme scheme, bool trace_ids = false,
47
                                  const std::string& trace_config = {});
48
49
CURLcode ApplySetOption(CURL* easy, const curl::fuzzer::proto::SetOption& option);
50
51
CURLcode ApplyTlsClientCredentialProfile(CURL* easy, curl::fuzzer::proto::TlsClientCredentialProfile profile);
52
53
std::size_t RuntimeOptionCount(const curl::fuzzer::proto::Scenario& scenario);
54
55
std::size_t ApplyScenarioOptions(CURL* easy, const curl::fuzzer::proto::Scenario& scenario);
56
57
}  // namespace proto_fuzzer
58
59
#endif  // PROTO_FUZZER_OPTION_APPLY_H_