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/ldaps_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 LDAP peer.
9
10
#include "proto_fuzzer/ldaps_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 LDAPS scenario. LDAP
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
4.52k
LdapsMockServer::LdapsMockServer() : transport_(TlsApplicationProtocol::kHttp11) {}
24
25
/// Release the TLS connection before the carrier-owned server context. The
26
/// inherited BER parser holds no transport state of its own.
27
4.52k
LdapsMockServer::~LdapsMockServer() { 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 LDAPS exchange.
34
4.51k
void LdapsMockServer::Install(CURL* easy) {
35
4.51k
  LdapMockServer::Install(easy);
36
4.51k
  transport_.Install(easy);
37
4.51k
}
38
39
/// Wrap one socketpair endpoint in an OpenSSL acceptor. The inherited BER loop
40
/// advances the handshake and then parses only decrypted LDAPMessages.
41
/// @return Newly allocated nonblocking TLS connection.
42
4.12k
std::unique_ptr<MockConnection> LdapsMockServer::CreateConnection() { return transport_.CreateConnection(); }
43
44
/// @return Protocol version selected by the most recent handshake, or zero.
45
4.51k
int LdapsMockServer::negotiated_tls_version() const { return transport_.negotiated_tls_version(); }
46
47
/// @return Number of connections that completed TLS negotiation.
48
4.51k
std::size_t LdapsMockServer::completed_handshake_count() const { return transport_.completed_handshake_count(); }
49
50
/// @return ALPN protocol selected by curl, or an empty string when absent.
51
4.51k
std::string LdapsMockServer::negotiated_alpn() const { return transport_.negotiated_alpn(); }
52
53
/// Retain protocol outcomes in coverage and introspector builds.
54
4.51k
void LdapsMockServer::ObserveState() {
55
4.51k
#if defined(PROTO_FUZZER_OBSERVE_STATE)
56
4.51k
  LdapMockServer::ObserveState();
57
4.51k
  const volatile std::size_t ldaps_observation[] = {
58
4.51k
      completed_handshake_count(), static_cast<std::size_t>(negotiated_tls_version()), negotiated_alpn().size()};
59
4.51k
  (void)ldaps_observation;
60
4.51k
#endif
61
4.51k
}
62
63
}  // namespace proto_fuzzer