curl-fuzzer C++ reference
Loading...
Searching...
No Matches
api_lifecycle.h
Go to the documentation of this file.
1/*
2 * Copyright (C) Max Dymond, <cmeister2@gmail.com>, et al.
3 *
4 * SPDX-License-Identifier: curl
5 */
6
9
10#ifndef PROTO_FUZZER_API_LIFECYCLE_H_
11#define PROTO_FUZZER_API_LIFECYCLE_H_
12
13#include <curl/curl.h>
14#include <curl/multi.h>
15
16#include <cstddef>
17#include <cstdint>
18#include <string_view>
19
20#include "curl_fuzzer.pb.h"
22
23namespace proto_fuzzer {
24
35 public:
36 ApiLifecycle(CURL* easy, const curl::fuzzer::proto::ApiPlan& plan, std::string_view url);
37
39 ApiLifecycle(CURL* easy, curl::fuzzer::proto::ApiPlan&& plan, std::string_view url) = delete;
40 ApiLifecycle(CURL* easy, const curl::fuzzer::proto::ApiPlan&& plan, std::string_view url) = delete;
41
43
44 ApiLifecycle(const ApiLifecycle&) = delete;
45 ApiLifecycle& operator=(const ApiLifecycle&) = delete;
46
47 void ProbeTransferResults(bool probe_upkeep);
48
50
51 bool response_pause_returned() const;
52
53 std::size_t response_bytes_received() const;
54
55 void SetActiveMulti(CURLM* multi);
56
57 std::size_t reentrant_probes_run() const;
58
59 std::size_t reentrant_recursive_rejections() const;
60
61 bool guessed_scheme_url() const;
62
63 bool version_info_probed() const;
64
65 bool https_proxy_feature_present() const;
66
67 private:
70 struct ShareCallbackState {
71 std::uint64_t locks = 0;
72 std::uint64_t unlocks = 0;
73 };
74
76 struct ResponseCallbackState {
77 ApiLifecycle* owner = nullptr;
78 bool pause_once = false;
79 bool pause_returned = false;
80 std::size_t bytes_received = 0;
81 bool probes_done = false;
82 std::size_t probes_run = 0;
83 std::size_t recursive_rejections = 0;
84 };
85
86 static std::size_t ResponseWrite(char* contents, std::size_t size, std::size_t nmemb, void* user_data);
87
88 void ConfigureShare();
89
90 static void ShareLock(CURL* easy, curl_lock_data data, curl_lock_access access, void* user_data);
91
92 static void ShareUnlock(CURL* easy, curl_lock_data data, void* user_data);
93
94 void CleanupShare();
95
96 void ProbeUrlAndEscaping(std::string_view url);
97
98 void RunReentrantProbes();
99
100 CURL* easy_;
101 const curl::fuzzer::proto::ApiPlan& plan_;
102 ResponseCallbackState response_callback_state_;
103 CURLSH* share_;
104 ShareCallbackState share_callback_state_;
105 CURLM* active_multi_;
106 bool guessed_scheme_url_;
107 bool version_info_probed_;
108 bool https_proxy_feature_present_;
109};
110
111} // namespace proto_fuzzer
112
113#endif // PROTO_FUZZER_API_LIFECYCLE_H_
Exercises public easy/share/query APIs while preserving all caller- owned option and callback lifetim...
~ApiLifecycle()
RunScenario keeps this owner alive through easy cleanup, which releases even an incomplete connection...
std::size_t reentrant_recursive_rejections() const
void ProbeEasyDuplication()
Duplicate, reset, and destroy a scratch easy handle while every pointer- valued option copied from th...
ApiLifecycle(CURL *easy, const curl::fuzzer::proto::ApiPlan &plan, std::string_view url)
Configure the plan's share handle and cover public error-string tables.
std::size_t reentrant_probes_run() const
void SetActiveMulti(CURLM *multi)
Hand the driving multi handle to the reentrancy probes so the multi-entry probes can target the live ...
ApiLifecycle(CURL *easy, curl::fuzzer::proto::ApiPlan &&plan, std::string_view url)=delete
A temporary plan cannot satisfy the retained reference's lifetime.
void ProbeTransferResults(bool probe_upkeep)
Run correctly typed CURLINFO and response-header probes selected by the plan.
bool https_proxy_feature_present() const
std::size_t response_bytes_received() const
Shared complexity limits for structured scenarios.