Coverage Report

Created: 2025-07-18 07:03

/src/bind9/lib/isc/openssl_shim.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3
 *
4
 * SPDX-License-Identifier: MPL-2.0
5
 *
6
 * This Source Code Form is subject to the terms of the Mozilla Public
7
 * License, v. 2.0. If a copy of the MPL was not distributed with this
8
 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
9
 *
10
 * See the COPYRIGHT file distributed with this work for additional
11
 * information regarding copyright ownership.
12
 */
13
14
#include <inttypes.h>
15
#include <stdlib.h>
16
#include <string.h>
17
18
#include <openssl/crypto.h>
19
#include <openssl/err.h>
20
#include <openssl/evp.h>
21
#include <openssl/opensslv.h>
22
#include <openssl/ssl.h>
23
24
#include <isc/util.h>
25
26
#include "openssl_shim.h"
27
28
#if !HAVE_BIO_READ_EX
29
int
30
BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes) {
31
  int rv = BIO_read(b, data, dlen);
32
  if (rv > 0) {
33
    *readbytes = rv;
34
    rv = 1;
35
  }
36
37
  return rv;
38
}
39
#endif /* !HAVE_BIO_READ_EX */
40
41
#if !HAVE_BIO_WRITE_EX
42
int
43
BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written) {
44
  int rv = BIO_write(b, data, dlen);
45
  if (rv > 0) {
46
    *written = rv;
47
    rv = 1;
48
  }
49
50
  return rv;
51
}
52
#endif /* !HAVE_BIO_WRITE_EX */
53
54
#if !HAVE_SSL_CTX_SET1_CERT_STORE
55
void
56
SSL_CTX_set1_cert_store(SSL_CTX *ctx, X509_STORE *store) {
57
  (void)X509_STORE_up_ref(store);
58
59
  SSL_CTX_set_cert_store(ctx, store);
60
}
61
#endif /* !HAVE_SSL_CTX_SET1_CERT_STORE */
62
63
#if !HAVE_ERR_GET_ERROR_ALL
64
static const char err_empty_string = '\0';
65
66
unsigned long
67
ERR_get_error_all(const char **file, int *line, const char **func,
68
0
      const char **data, int *flags) {
69
0
  SET_IF_NOT_NULL(func, &err_empty_string);
70
0
  return ERR_get_error_line_data(file, line, data, flags);
71
0
}
72
#endif /* if !HAVE_ERR_GET_ERROR_ALL */