Coverage Report

Created: 2026-10-28 07:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/curl_fuzzer/proto_fuzzer/smtps_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 SMTP peer.
9
10
#include "proto_fuzzer/smtps_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 SMTPS scenario. SMTP
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
2.07k
SmtpsMockServer::SmtpsMockServer() : transport_(TlsApplicationProtocol::kHttp11) {}
24
25
/// Release the TLS connection before the carrier-owned server context. The
26
/// inherited command parser holds no transport state of its own.
27
2.07k
SmtpsMockServer::~SmtpsMockServer() { 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 SMTPS exchange.
34
2.07k
void SmtpsMockServer::Install(CURL* easy) {
35
2.07k
  SmtpMockServer::Install(easy);
36
2.07k
  transport_.Install(easy);
37
2.07k
}
38
39
/// Wrap one socketpair endpoint in an OpenSSL acceptor. The inherited SMTP
40
/// loop advances the handshake and then parses only decrypted commands.
41
/// @return Newly allocated nonblocking TLS connection.
42
1.93k
std::unique_ptr<MockConnection> SmtpsMockServer::CreateConnection() { return transport_.CreateConnection(); }
43
44
/// @return Protocol version selected by the most recent handshake, or zero.
45
2.07k
int SmtpsMockServer::negotiated_tls_version() const { return transport_.negotiated_tls_version(); }
46
47
/// @return Number of connections that completed TLS negotiation.
48
2.07k
std::size_t SmtpsMockServer::completed_handshake_count() const { return transport_.completed_handshake_count(); }
49
50
/// @return ALPN protocol selected by curl, or an empty string when absent.
51
2.07k
std::string SmtpsMockServer::negotiated_alpn() const { return transport_.negotiated_alpn(); }
52
53
}  // namespace proto_fuzzer