Coverage Report

Created: 2026-12-01 06:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/curl_fuzzer/openssl_contract_shim.cc
Line
Count
Source
1
/*
2
 * Copyright (C) Max Dymond, <cmeister2@gmail.com>, et al.
3
 *
4
 * SPDX-License-Identifier: curl
5
 */
6
7
#include <openssl/ssl.h>
8
9
#include <array>
10
#include <atomic>
11
#include <cstddef>
12
#include <cstdio>
13
#include <cstdlib>
14
#include <mutex>
15
#include <type_traits>
16
17
namespace {
18
19
// SSL_get_error classifies a preceding I/O result for one SSL object. Keep
20
// pending results keyed by that object so interleaved connections cannot
21
// replace one another's classification state.
22
struct PendingIoCall {
23
  const SSL *ssl = nullptr;
24
  const char *api = nullptr;
25
  long long result = 0;
26
};
27
28
struct FatalConnection {
29
  const SSL *ssl = nullptr;
30
  const char *io_api = nullptr;
31
  long long io_result = 0;
32
  int ssl_error = SSL_ERROR_NONE;
33
};
34
35
// Fixed tables keep allocation-failure fuzzing from disabling or perturbing
36
// the monitor.
37
constexpr std::size_t kMaximumTrackedConnections = 256;
38
std::array<PendingIoCall, kMaximumTrackedConnections> pending_io_calls{};
39
std::mutex pending_io_calls_mutex;
40
std::atomic<std::size_t> pending_io_call_count{0};
41
42
constexpr std::size_t kMaximumFatalConnections = kMaximumTrackedConnections;
43
std::array<FatalConnection, kMaximumFatalConnections> fatal_connections{};
44
std::mutex fatal_connections_mutex;
45
std::atomic<std::size_t> fatal_connection_count{0};
46
47
// Static libssl contains calls to public SSL APIs. --wrap redirects those
48
// calls too, so calls made while a real OpenSSL function is running bypass the
49
// monitor and cannot replace the application call being classified.
50
thread_local unsigned real_call_depth = 0;
51
52
class RealCallScope {
53
public:
54
294M
  RealCallScope() { ++real_call_depth; }
55
294M
  ~RealCallScope() { --real_call_depth; }
56
57
  RealCallScope(const RealCallScope &) = delete;
58
  RealCallScope &operator=(const RealCallScope &) = delete;
59
};
60
61
294M
bool IsRealCallActive() { return real_call_depth != 0; }
62
63
0
const char *ErrorName(int ssl_error) {
64
0
  switch (ssl_error) {
65
0
  case SSL_ERROR_SSL:
66
0
    return "SSL_ERROR_SSL";
67
0
  case SSL_ERROR_SYSCALL:
68
0
    return "SSL_ERROR_SYSCALL";
69
0
  default:
70
0
    return "unknown fatal error";
71
0
  }
72
0
}
73
74
[[noreturn]] void AbortContractViolation(const char *attempted_api,
75
0
                                         const FatalConnection &fatal) {
76
0
  std::fprintf(stderr,
77
0
               "OpenSSL contract assertion failed: %s called on SSL %p "
78
0
               "after %s returned %lld and SSL_get_error classified it as "
79
0
               "%s; no further I/O or SSL_shutdown is allowed\n",
80
0
               attempted_api, static_cast<const void *>(fatal.ssl),
81
0
               fatal.io_api, fatal.io_result, ErrorName(fatal.ssl_error));
82
0
  std::fflush(stderr);
83
0
  std::abort();
84
0
}
85
86
0
[[noreturn]] void AbortPendingOverflow(const PendingIoCall &call) {
87
0
  std::fprintf(stderr,
88
0
               "OpenSSL contract assertion failed: cannot track SSL %p "
89
0
               "after %s returned %lld; pending-I/O table is full\n",
90
0
               static_cast<const void *>(call.ssl), call.api, call.result);
91
0
  std::fflush(stderr);
92
0
  std::abort();
93
0
}
94
95
0
[[noreturn]] void AbortFatalOverflow(const PendingIoCall &call, int ssl_error) {
96
0
  std::fprintf(stderr,
97
0
               "OpenSSL contract assertion failed: cannot track SSL %p "
98
0
               "after %s returned %lld and SSL_get_error classified it as "
99
0
               "%s; fatal-connection table is full\n",
100
0
               static_cast<const void *>(call.ssl), call.api, call.result,
101
0
               ErrorName(ssl_error));
102
0
  std::fflush(stderr);
103
0
  std::abort();
104
0
}
105
106
291M
PendingIoCall *FindPendingIoCall(const SSL *ssl) {
107
37.4G
  for (PendingIoCall &call : pending_io_calls) {
108
37.4G
    if (call.ssl == ssl) {
109
145M
      return &call;
110
145M
    }
111
37.4G
  }
112
145M
  return nullptr;
113
291M
}
114
115
66.0k
FatalConnection *FindFatalConnection(const SSL *ssl) {
116
12.1M
  for (FatalConnection &fatal : fatal_connections) {
117
12.1M
    if (fatal.ssl == ssl) {
118
18.5k
      return &fatal;
119
18.5k
    }
120
12.1M
  }
121
47.4k
  return nullptr;
122
66.0k
}
123
124
148M
void CheckUsable(const SSL *ssl, const char *attempted_api) {
125
148M
  if (ssl == nullptr ||
126
148M
      fatal_connection_count.load(std::memory_order_acquire) == 0) {
127
148M
    return;
128
148M
  }
129
130
25.8k
  FatalConnection fatal;
131
25.8k
  {
132
25.8k
    std::lock_guard<std::mutex> lock(fatal_connections_mutex);
133
25.8k
    const FatalConnection *tracked = FindFatalConnection(ssl);
134
25.8k
    if (tracked != nullptr) {
135
0
      fatal = *tracked;
136
0
    }
137
25.8k
  }
138
25.8k
  if (fatal.ssl != nullptr) {
139
0
    AbortContractViolation(attempted_api, fatal);
140
0
  }
141
25.8k
}
142
143
3.00M
void ForgetPendingIoCall(const SSL *ssl) {
144
3.00M
  if (ssl == nullptr ||
145
3.00M
      pending_io_call_count.load(std::memory_order_acquire) == 0) {
146
3.00M
    return;
147
3.00M
  }
148
149
1.12k
  std::lock_guard<std::mutex> lock(pending_io_calls_mutex);
150
1.12k
  PendingIoCall *call = FindPendingIoCall(ssl);
151
1.12k
  if (call != nullptr) {
152
1.12k
    *call = PendingIoCall{};
153
1.12k
    pending_io_call_count.fetch_sub(1, std::memory_order_release);
154
1.12k
  }
155
1.12k
}
156
157
void RecordIoResult(const SSL *ssl, const char *api, long long result,
158
148M
                    bool zero_is_non_error = false) {
159
148M
  if (ssl == nullptr) {
160
0
    return;
161
0
  }
162
148M
  if (result > 0 || (zero_is_non_error && result == 0)) {
163
2.42M
    ForgetPendingIoCall(ssl);
164
2.42M
    return;
165
2.42M
  }
166
167
145M
  PendingIoCall recorded;
168
145M
  recorded.ssl = ssl;
169
145M
  recorded.api = api;
170
145M
  recorded.result = result;
171
145M
  bool table_full = false;
172
145M
  bool added = false;
173
145M
  {
174
145M
    std::lock_guard<std::mutex> lock(pending_io_calls_mutex);
175
145M
    PendingIoCall *call = FindPendingIoCall(ssl);
176
145M
    if (call == nullptr) {
177
145M
      for (PendingIoCall &entry : pending_io_calls) {
178
145M
        if (entry.ssl == nullptr) {
179
145M
          call = &entry;
180
145M
          added = true;
181
145M
          break;
182
145M
        }
183
145M
      }
184
145M
    }
185
145M
    if (call != nullptr) {
186
145M
      *call = recorded;
187
145M
      if (added) {
188
145M
        pending_io_call_count.fetch_add(1, std::memory_order_release);
189
145M
      }
190
145M
    } else {
191
0
      table_full = true;
192
0
    }
193
145M
  }
194
145M
  if (table_full) {
195
0
    AbortPendingOverflow(recorded);
196
0
  }
197
145M
}
198
199
145M
void RecordSslError(const SSL *ssl, int io_result, int ssl_error) {
200
145M
  if (ssl == nullptr ||
201
145M
      pending_io_call_count.load(std::memory_order_acquire) == 0) {
202
432
    return;
203
432
  }
204
205
145M
  PendingIoCall classified_call;
206
145M
  {
207
145M
    std::lock_guard<std::mutex> lock(pending_io_calls_mutex);
208
145M
    PendingIoCall *pending = FindPendingIoCall(ssl);
209
145M
    if (pending == nullptr || pending->result != io_result) {
210
0
      return;
211
0
    }
212
145M
    classified_call = *pending;
213
145M
    *pending = PendingIoCall{};
214
145M
    pending_io_call_count.fetch_sub(1, std::memory_order_release);
215
145M
  }
216
145M
  if (ssl_error != SSL_ERROR_SSL && ssl_error != SSL_ERROR_SYSCALL) {
217
145M
    return;
218
145M
  }
219
220
18.5k
  bool table_full = false;
221
18.5k
  bool added = false;
222
18.5k
  {
223
18.5k
    std::lock_guard<std::mutex> lock(fatal_connections_mutex);
224
18.5k
    FatalConnection *fatal = FindFatalConnection(ssl);
225
18.5k
    if (fatal == nullptr) {
226
19.5k
      for (FatalConnection &entry : fatal_connections) {
227
19.5k
        if (entry.ssl == nullptr) {
228
18.5k
          fatal = &entry;
229
18.5k
          added = true;
230
18.5k
          break;
231
18.5k
        }
232
19.5k
      }
233
18.5k
    }
234
18.5k
    if (fatal != nullptr) {
235
18.5k
      fatal->ssl = ssl;
236
18.5k
      fatal->io_api = classified_call.api;
237
18.5k
      fatal->io_result = classified_call.result;
238
18.5k
      fatal->ssl_error = ssl_error;
239
18.5k
      if (added) {
240
18.5k
        fatal_connection_count.fetch_add(1, std::memory_order_release);
241
18.5k
      }
242
18.5k
    } else {
243
0
      table_full = true;
244
0
    }
245
18.5k
  }
246
18.5k
  if (table_full) {
247
0
    AbortFatalOverflow(classified_call, ssl_error);
248
0
  }
249
18.5k
}
250
251
578k
void ForgetConnection(const SSL *ssl) {
252
578k
  ForgetPendingIoCall(ssl);
253
578k
  if (ssl == nullptr ||
254
578k
      fatal_connection_count.load(std::memory_order_acquire) == 0) {
255
556k
    return;
256
556k
  }
257
258
21.6k
  std::lock_guard<std::mutex> lock(fatal_connections_mutex);
259
21.6k
  FatalConnection *fatal = FindFatalConnection(ssl);
260
21.6k
  if (fatal != nullptr) {
261
18.5k
    *fatal = FatalConnection{};
262
18.5k
    fatal_connection_count.fetch_sub(1, std::memory_order_release);
263
18.5k
  }
264
21.6k
}
265
266
} // namespace
267
268
// GNU ld and lld provide each __real_* symbol when the final link uses the
269
// matching --wrap option. decltype ties these declarations to the installed
270
// OpenSSL headers and makes signature drift a compile-time failure.
271
extern "C" decltype(SSL_new) __real_SSL_new;
272
extern "C" decltype(SSL_free) __real_SSL_free;
273
extern "C" decltype(SSL_clear) __real_SSL_clear;
274
extern "C" decltype(SSL_get_error) __real_SSL_get_error;
275
extern "C" decltype(SSL_accept) __real_SSL_accept;
276
extern "C" decltype(SSL_connect) __real_SSL_connect;
277
extern "C" decltype(SSL_do_handshake) __real_SSL_do_handshake;
278
extern "C" decltype(SSL_read) __real_SSL_read;
279
extern "C" decltype(SSL_read_ex) __real_SSL_read_ex;
280
extern "C" decltype(SSL_read_early_data) __real_SSL_read_early_data;
281
extern "C" decltype(SSL_peek) __real_SSL_peek;
282
extern "C" decltype(SSL_peek_ex) __real_SSL_peek_ex;
283
extern "C" decltype(SSL_sendfile) __real_SSL_sendfile;
284
extern "C" decltype(SSL_write) __real_SSL_write;
285
extern "C" decltype(SSL_write_ex) __real_SSL_write_ex;
286
extern "C" decltype(SSL_write_ex2) __real_SSL_write_ex2;
287
extern "C" decltype(SSL_write_early_data) __real_SSL_write_early_data;
288
extern "C" decltype(SSL_shutdown) __real_SSL_shutdown;
289
extern "C" decltype(SSL_shutdown_ex) __real_SSL_shutdown_ex;
290
291
289k
extern "C" SSL *__wrap_SSL_new(SSL_CTX *ctx) {
292
289k
  if (IsRealCallActive()) {
293
0
    return __real_SSL_new(ctx);
294
0
  }
295
289k
  SSL *ssl;
296
289k
  {
297
289k
    RealCallScope real_call;
298
289k
    ssl = __real_SSL_new(ctx);
299
289k
  }
300
  // OpenSSL's allocator may reuse a recently freed address.
301
289k
  ForgetConnection(ssl);
302
289k
  return ssl;
303
289k
}
304
static_assert(std::is_same<decltype(SSL_new), decltype(__wrap_SSL_new)>::value,
305
              "SSL_new signature changed");
306
307
289k
extern "C" void __wrap_SSL_free(SSL *ssl) {
308
289k
  if (IsRealCallActive()) {
309
0
    __real_SSL_free(ssl);
310
0
    return;
311
0
  }
312
289k
  ForgetConnection(ssl);
313
289k
  RealCallScope real_call;
314
289k
  __real_SSL_free(ssl);
315
289k
}
316
static_assert(
317
    std::is_same<decltype(SSL_free), decltype(__wrap_SSL_free)>::value,
318
    "SSL_free signature changed");
319
320
281k
extern "C" int __wrap_SSL_clear(SSL *ssl) {
321
281k
  if (IsRealCallActive()) {
322
281k
    return __real_SSL_clear(ssl);
323
281k
  }
324
0
  int result;
325
0
  {
326
0
    RealCallScope real_call;
327
0
    result = __real_SSL_clear(ssl);
328
0
  }
329
0
  if (result == 1) {
330
    // A successful clear starts a new connection on the same SSL object.
331
0
    ForgetConnection(ssl);
332
0
  }
333
0
  return result;
334
281k
}
335
static_assert(
336
    std::is_same<decltype(SSL_clear), decltype(__wrap_SSL_clear)>::value,
337
    "SSL_clear signature changed");
338
339
145M
extern "C" int __wrap_SSL_get_error(const SSL *ssl, int io_result) {
340
145M
  if (IsRealCallActive()) {
341
1.16k
    return __real_SSL_get_error(ssl, io_result);
342
1.16k
  }
343
145M
  int ssl_error;
344
145M
  {
345
145M
    RealCallScope real_call;
346
145M
    ssl_error = __real_SSL_get_error(ssl, io_result);
347
145M
  }
348
145M
  RecordSslError(ssl, io_result, ssl_error);
349
145M
  return ssl_error;
350
145M
}
351
static_assert(std::is_same<decltype(SSL_get_error),
352
                           decltype(__wrap_SSL_get_error)>::value,
353
              "SSL_get_error signature changed");
354
355
#define DEFINE_IO_WRAPPER_WITH_POLICY(name, parameters, arguments,             \
356
                                      zero_is_non_error)                       \
357
  extern "C" auto __wrap_##name parameters                                     \
358
148M
      ->decltype(__real_##name arguments) {                                    \
359
148M
    if (IsRealCallActive()) {                                                  \
360
0
      return __real_##name arguments;                                          \
361
0
    }                                                                          \
362
148M
    CheckUsable(ssl, #name);                                                   \
363
148M
    decltype(__real_##name arguments) result;                                  \
364
148M
    {                                                                          \
365
148M
      RealCallScope real_call;                                                 \
366
148M
      result = __real_##name arguments;                                        \
367
148M
    }                                                                          \
368
148M
    RecordIoResult(ssl, #name, static_cast<long long>(result),                 \
369
148M
                   zero_is_non_error);                                         \
370
148M
    return result;                                                             \
371
148M
  }                                                                            \
__wrap_SSL_accept
Line
Count
Source
358
488k
      ->decltype(__real_##name arguments) {                                    \
359
488k
    if (IsRealCallActive()) {                                                  \
360
0
      return __real_##name arguments;                                          \
361
0
    }                                                                          \
362
488k
    CheckUsable(ssl, #name);                                                   \
363
488k
    decltype(__real_##name arguments) result;                                  \
364
488k
    {                                                                          \
365
488k
      RealCallScope real_call;                                                 \
366
488k
      result = __real_##name arguments;                                        \
367
488k
    }                                                                          \
368
488k
    RecordIoResult(ssl, #name, static_cast<long long>(result),                 \
369
488k
                   zero_is_non_error);                                         \
370
488k
    return result;                                                             \
371
488k
  }                                                                            \
__wrap_SSL_connect
Line
Count
Source
358
210k
      ->decltype(__real_##name arguments) {                                    \
359
210k
    if (IsRealCallActive()) {                                                  \
360
0
      return __real_##name arguments;                                          \
361
0
    }                                                                          \
362
210k
    CheckUsable(ssl, #name);                                                   \
363
210k
    decltype(__real_##name arguments) result;                                  \
364
210k
    {                                                                          \
365
210k
      RealCallScope real_call;                                                 \
366
210k
      result = __real_##name arguments;                                        \
367
210k
    }                                                                          \
368
210k
    RecordIoResult(ssl, #name, static_cast<long long>(result),                 \
369
210k
                   zero_is_non_error);                                         \
370
210k
    return result;                                                             \
371
210k
  }                                                                            \
__wrap_SSL_do_handshake
Line
Count
Source
358
31.1k
      ->decltype(__real_##name arguments) {                                    \
359
31.1k
    if (IsRealCallActive()) {                                                  \
360
0
      return __real_##name arguments;                                          \
361
0
    }                                                                          \
362
31.1k
    CheckUsable(ssl, #name);                                                   \
363
31.1k
    decltype(__real_##name arguments) result;                                  \
364
31.1k
    {                                                                          \
365
31.1k
      RealCallScope real_call;                                                 \
366
31.1k
      result = __real_##name arguments;                                        \
367
31.1k
    }                                                                          \
368
31.1k
    RecordIoResult(ssl, #name, static_cast<long long>(result),                 \
369
31.1k
                   zero_is_non_error);                                         \
370
31.1k
    return result;                                                             \
371
31.1k
  }                                                                            \
__wrap_SSL_read
Line
Count
Source
358
1.31M
      ->decltype(__real_##name arguments) {                                    \
359
1.31M
    if (IsRealCallActive()) {                                                  \
360
0
      return __real_##name arguments;                                          \
361
0
    }                                                                          \
362
1.31M
    CheckUsable(ssl, #name);                                                   \
363
1.31M
    decltype(__real_##name arguments) result;                                  \
364
1.31M
    {                                                                          \
365
1.31M
      RealCallScope real_call;                                                 \
366
1.31M
      result = __real_##name arguments;                                        \
367
1.31M
    }                                                                          \
368
1.31M
    RecordIoResult(ssl, #name, static_cast<long long>(result),                 \
369
1.31M
                   zero_is_non_error);                                         \
370
1.31M
    return result;                                                             \
371
1.31M
  }                                                                            \
__wrap_SSL_read_ex
Line
Count
Source
358
2.34M
      ->decltype(__real_##name arguments) {                                    \
359
2.34M
    if (IsRealCallActive()) {                                                  \
360
0
      return __real_##name arguments;                                          \
361
0
    }                                                                          \
362
2.34M
    CheckUsable(ssl, #name);                                                   \
363
2.34M
    decltype(__real_##name arguments) result;                                  \
364
2.34M
    {                                                                          \
365
2.34M
      RealCallScope real_call;                                                 \
366
2.34M
      result = __real_##name arguments;                                        \
367
2.34M
    }                                                                          \
368
2.34M
    RecordIoResult(ssl, #name, static_cast<long long>(result),                 \
369
2.34M
                   zero_is_non_error);                                         \
370
2.34M
    return result;                                                             \
371
2.34M
  }                                                                            \
Unexecuted instantiation: __wrap_SSL_read_early_data
Unexecuted instantiation: __wrap_SSL_peek
Unexecuted instantiation: __wrap_SSL_peek_ex
Unexecuted instantiation: __wrap_SSL_sendfile
__wrap_SSL_write
Line
Count
Source
358
143M
      ->decltype(__real_##name arguments) {                                    \
359
143M
    if (IsRealCallActive()) {                                                  \
360
0
      return __real_##name arguments;                                          \
361
0
    }                                                                          \
362
143M
    CheckUsable(ssl, #name);                                                   \
363
143M
    decltype(__real_##name arguments) result;                                  \
364
143M
    {                                                                          \
365
143M
      RealCallScope real_call;                                                 \
366
143M
      result = __real_##name arguments;                                        \
367
143M
    }                                                                          \
368
143M
    RecordIoResult(ssl, #name, static_cast<long long>(result),                 \
369
143M
                   zero_is_non_error);                                         \
370
143M
    return result;                                                             \
371
143M
  }                                                                            \
__wrap_SSL_write_ex
Line
Count
Source
358
363k
      ->decltype(__real_##name arguments) {                                    \
359
363k
    if (IsRealCallActive()) {                                                  \
360
0
      return __real_##name arguments;                                          \
361
0
    }                                                                          \
362
363k
    CheckUsable(ssl, #name);                                                   \
363
363k
    decltype(__real_##name arguments) result;                                  \
364
363k
    {                                                                          \
365
363k
      RealCallScope real_call;                                                 \
366
363k
      result = __real_##name arguments;                                        \
367
363k
    }                                                                          \
368
363k
    RecordIoResult(ssl, #name, static_cast<long long>(result),                 \
369
363k
                   zero_is_non_error);                                         \
370
363k
    return result;                                                             \
371
363k
  }                                                                            \
Unexecuted instantiation: __wrap_SSL_write_ex2
__wrap_SSL_write_early_data
Line
Count
Source
358
152
      ->decltype(__real_##name arguments) {                                    \
359
152
    if (IsRealCallActive()) {                                                  \
360
0
      return __real_##name arguments;                                          \
361
0
    }                                                                          \
362
152
    CheckUsable(ssl, #name);                                                   \
363
152
    decltype(__real_##name arguments) result;                                  \
364
152
    {                                                                          \
365
152
      RealCallScope real_call;                                                 \
366
152
      result = __real_##name arguments;                                        \
367
152
    }                                                                          \
368
152
    RecordIoResult(ssl, #name, static_cast<long long>(result),                 \
369
152
                   zero_is_non_error);                                         \
370
152
    return result;                                                             \
371
152
  }                                                                            \
__wrap_SSL_shutdown
Line
Count
Source
358
173k
      ->decltype(__real_##name arguments) {                                    \
359
173k
    if (IsRealCallActive()) {                                                  \
360
0
      return __real_##name arguments;                                          \
361
0
    }                                                                          \
362
173k
    CheckUsable(ssl, #name);                                                   \
363
173k
    decltype(__real_##name arguments) result;                                  \
364
173k
    {                                                                          \
365
173k
      RealCallScope real_call;                                                 \
366
173k
      result = __real_##name arguments;                                        \
367
173k
    }                                                                          \
368
173k
    RecordIoResult(ssl, #name, static_cast<long long>(result),                 \
369
173k
                   zero_is_non_error);                                         \
370
173k
    return result;                                                             \
371
173k
  }                                                                            \
Unexecuted instantiation: __wrap_SSL_shutdown_ex
372
  static_assert(std::is_same<decltype(name), decltype(__wrap_##name)>::value,  \
373
                #name " signature changed");
374
375
#define DEFINE_IO_WRAPPER(name, parameters, arguments)                         \
376
  DEFINE_IO_WRAPPER_WITH_POLICY(name, parameters, arguments, false)
377
378
#define DEFINE_ZERO_NONERROR_WRAPPER(name, parameters, arguments)              \
379
  DEFINE_IO_WRAPPER_WITH_POLICY(name, parameters, arguments, true)
380
381
DEFINE_IO_WRAPPER(SSL_accept, (SSL * ssl), (ssl))
382
DEFINE_IO_WRAPPER(SSL_connect, (SSL * ssl), (ssl))
383
DEFINE_IO_WRAPPER(SSL_do_handshake, (SSL * ssl), (ssl))
384
DEFINE_IO_WRAPPER(SSL_read, (SSL * ssl, void *buffer, int length),
385
                  (ssl, buffer, length))
386
DEFINE_IO_WRAPPER(SSL_read_ex,
387
                  (SSL * ssl, void *buffer, size_t length, size_t *readbytes),
388
                  (ssl, buffer, length, readbytes))
389
DEFINE_IO_WRAPPER(SSL_read_early_data,
390
                  (SSL * ssl, void *buffer, size_t length, size_t *readbytes),
391
                  (ssl, buffer, length, readbytes))
392
DEFINE_IO_WRAPPER(SSL_peek, (SSL * ssl, void *buffer, int length),
393
                  (ssl, buffer, length))
394
DEFINE_IO_WRAPPER(SSL_peek_ex,
395
                  (SSL * ssl, void *buffer, size_t length, size_t *readbytes),
396
                  (ssl, buffer, length, readbytes))
397
DEFINE_ZERO_NONERROR_WRAPPER(SSL_sendfile,
398
                             (SSL * ssl, int fd, off_t offset, size_t size,
399
                              int flags),
400
                             (ssl, fd, offset, size, flags))
401
DEFINE_IO_WRAPPER(SSL_write, (SSL * ssl, const void *buffer, int length),
402
                  (ssl, buffer, length))
403
DEFINE_IO_WRAPPER(SSL_write_ex,
404
                  (SSL * ssl, const void *buffer, size_t length,
405
                   size_t *written),
406
                  (ssl, buffer, length, written))
407
DEFINE_IO_WRAPPER(SSL_write_ex2,
408
                  (SSL * ssl, const void *buffer, size_t length, uint64_t flags,
409
                   size_t *written),
410
                  (ssl, buffer, length, flags, written))
411
DEFINE_IO_WRAPPER(SSL_write_early_data,
412
                  (SSL * ssl, const void *buffer, size_t length,
413
                   size_t *written),
414
                  (ssl, buffer, length, written))
415
DEFINE_ZERO_NONERROR_WRAPPER(SSL_shutdown, (SSL * ssl), (ssl))
416
DEFINE_ZERO_NONERROR_WRAPPER(SSL_shutdown_ex,
417
                             (SSL * ssl, uint64_t flags,
418
                              const SSL_SHUTDOWN_EX_ARGS *args,
419
                              size_t args_length),
420
                             (ssl, flags, args, args_length))
421
422
#undef DEFINE_ZERO_NONERROR_WRAPPER
423
#undef DEFINE_IO_WRAPPER
424
#undef DEFINE_IO_WRAPPER_WITH_POLICY