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/ftps_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 FTP peer.
9
10
#include "proto_fuzzer/ftps_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 FTPS scenario. FTP
21
/// sends no ALPN extension, so the closed HTTP/1.1 default is never selected
22
/// and each control or data handshake completes without an application
23
/// protocol.
24
1.95k
FtpsMockServer::FtpsMockServer() : transport_(TlsApplicationProtocol::kHttp11) {}
25
26
/// Release the TLS connections before the carrier-owned server context. The
27
/// inherited FTP peer owns both the control and passive data connections, so
28
/// resetting only the base's generic connection would leave their SSL objects
29
/// alive past this transport's lifetime.
30
1.95k
FtpsMockServer::~FtpsMockServer() { ReleaseConnections(); }
31
32
/// Install the shared socket callbacks and a stable local trust anchor. Curl
33
/// copies the blob descriptor during setopt and borrows the inline certificate
34
/// bytes, whose program lifetime safely exceeds every easy handle. Scenario
35
/// options run afterwards and can still disable verification.
36
/// @param easy Easy handle that will initiate the FTPS control connection.
37
1.94k
void FtpsMockServer::Install(CURL* easy) {
38
1.94k
  FtpMockServer::Install(easy);
39
1.94k
  transport_.Install(easy);
40
1.94k
}
41
42
/// Wrap one control or passive-data socketpair endpoint in an OpenSSL
43
/// acceptor. The inherited FTP loop advances each handshake and then parses
44
/// only decrypted control replies or drains decrypted upload bytes.
45
/// @return Newly allocated nonblocking TLS connection.
46
2.72k
std::unique_ptr<MockConnection> FtpsMockServer::CreateConnection() { return transport_.CreateConnection(); }
47
48
/// Reject active-mode listener creation. FTPS data channels must carry TLS,
49
/// but curl's PORT/EPRT path expects a real loopback TCP socket that this
50
/// peer cannot wrap; the lane therefore stays on EPSV/PASV.
51
/// @return false for every FTPS drive.
52
0
bool FtpsMockServer::SupportsActiveMode() const { return false; }
53
54
/// @return Protocol version selected by the most recent handshake, or zero.
55
1.94k
int FtpsMockServer::negotiated_tls_version() const { return transport_.negotiated_tls_version(); }
56
57
/// @return Number of control and data connections that completed TLS
58
///         negotiation.
59
1.94k
std::size_t FtpsMockServer::completed_handshake_count() const { return transport_.completed_handshake_count(); }
60
61
/// @return ALPN protocol selected by curl, or an empty string when absent.
62
1.94k
std::string FtpsMockServer::negotiated_alpn() const { return transport_.negotiated_alpn(); }
63
64
}  // namespace proto_fuzzer