15namespace proto_fuzzer {
21class ScopedEnvironmentOverride {
23 ScopedEnvironmentOverride(
const char* name,
const char* value) : name_(name) {
24 const char* previous = std::getenv(name);
25 if (previous !=
nullptr) {
29 active_ = setenv(name, value, 1) == 0;
32 ~ScopedEnvironmentOverride() {
37 (void)setenv(name_.c_str(), previous_.c_str(), 1);
39 (void)unsetenv(name_.c_str());
43 ScopedEnvironmentOverride(
const ScopedEnvironmentOverride&) =
delete;
44 ScopedEnvironmentOverride& operator=(
const ScopedEnvironmentOverride&) =
delete;
48 std::string previous_;
49 bool had_previous_ =
false;
53constexpr int kTimeoutProbeBufferBytes = 2048;
54constexpr long kTimeoutProbeMilliseconds = 5;
62GopherMockServer::~GopherMockServer() =
default;
70 if (mode_ != curl::fuzzer::proto::GOPHER_PROBE_SEND_TIMEOUT) {
76 connection->ApplyBackpressure(kTimeoutProbeBufferBytes, 0);
89 if (mode_ == curl::fuzzer::proto::GOPHER_PROBE_PARTIAL_WRITE_NO_TIMEOUT) {
90 (void)curl_easy_setopt(easy, CURLOPT_TIMEOUT_MS, 0L);
91 ScopedEnvironmentOverride partial_writes(
"CURL_DBG_SOCK_WPARTIAL",
"50");
95 if (mode_ == curl::fuzzer::proto::GOPHER_PROBE_SEND_TIMEOUT) {
96 (void)curl_easy_setopt(easy, CURLOPT_TIMEOUT_MS, kTimeoutProbeMilliseconds);
GopherMockServer(curl::fuzzer::proto::GopherProbeMode mode)
Construct a closed Gopher probe peer.
void RunLoop(CURLM *multi, CURL *easy, const curl::fuzzer::proto::Scenario &scenario) override
Apply the two fixed timing policies immediately before curl's first perform.
std::unique_ptr< MockConnection > CreateConnection() override
Build an ordinary socketpair, then saturate the client-to-server direction for the timeout probe befo...
MockConnection * connection()
void RunLoop(CURLM *multi, CURL *easy, const curl::fuzzer::proto::Scenario &scenario) override
Seed the mock from the scenario, then drive the perform loop until curl is done or a deterministic op...
virtual std::unique_ptr< MockConnection > CreateConnection()
Construct the transport used for one HTTP exchange.
Bounded transport probes for curl's synchronous Gopher selector.