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/pop3s_mock_server.cc
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 Implementation of the implicit-TLS POP3 peer.
9
10
#include "proto_fuzzer/pop3s_mock_server.h"
11
12
#include <cstddef>
13
#include <memory>
14
#include <string>
15
16
#include "proto_fuzzer/mock_server.h"
17
18
namespace proto_fuzzer {
19
20
/// Construct the OpenSSL server carrier used by every POP3S scenario. POP3
21
/// sends no ALPN extension, so the closed HTTP/1.1 default is never selected
22
/// and the handshake completes without an application protocol.
23
3.17k
Pop3sMockServer::Pop3sMockServer() : transport_(TlsApplicationProtocol::kHttp11) {}
24
25
/// Release the TLS connection before the carrier-owned server context. The
26
/// inherited status-line parser holds no transport state of its own.
27
3.17k
Pop3sMockServer::~Pop3sMockServer() { connection_.reset(); }
28
29
/// Install the shared socket callbacks and a stable local trust anchor. Curl
30
/// copies the blob descriptor during setopt and borrows the inline certificate
31
/// bytes, whose program lifetime safely exceeds every easy handle. Scenario
32
/// options run afterwards and can still disable verification.
33
/// @param easy Easy handle that will initiate the POP3S exchange.
34
3.15k
void Pop3sMockServer::Install(CURL* easy) {
35
3.15k
  Pop3MockServer::Install(easy);
36
3.15k
  transport_.Install(easy);
37
3.15k
}
38
39
/// Wrap one socketpair endpoint in an OpenSSL acceptor. The inherited POP3
40
/// loop advances the handshake and then parses only decrypted commands.
41
/// @return Newly allocated nonblocking TLS connection.
42
2.84k
std::unique_ptr<MockConnection> Pop3sMockServer::CreateConnection() { return transport_.CreateConnection(); }
43
44
/// @return Protocol version selected by the most recent handshake, or zero.
45
3.15k
int Pop3sMockServer::negotiated_tls_version() const { return transport_.negotiated_tls_version(); }
46
47
/// @return Number of connections that completed TLS negotiation.
48
3.15k
std::size_t Pop3sMockServer::completed_handshake_count() const { return transport_.completed_handshake_count(); }
49
50
/// @return ALPN protocol selected by curl, or an empty string when absent.
51
3.15k
std::string Pop3sMockServer::negotiated_alpn() const { return transport_.negotiated_alpn(); }
52
53
/// Retain protocol outcomes in coverage and introspector builds.
54
3.15k
void Pop3sMockServer::ObserveState() {
55
3.15k
#if defined(PROTO_FUZZER_OBSERVE_STATE)
56
3.15k
  Pop3MockServer::ObserveState();
57
3.15k
  const volatile std::size_t pop3s_observation[] = {
58
3.15k
      completed_handshake_count(), static_cast<std::size_t>(negotiated_tls_version()), negotiated_alpn().size()};
59
3.15k
  (void)pop3s_observation;
60
3.15k
#endif
61
3.15k
}
62
63
}  // namespace proto_fuzzer