Coverage Report

Created: 2025-12-08 06:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl/crypto/conf/conf_sap.c
Line
Count
Source
1
/*
2
 * Copyright 2002-2024 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License 2.0 (the "License").  You may not use
5
 * this file except in compliance with the License.  You can obtain a copy
6
 * in the file LICENSE in the source distribution or at
7
 * https://www.openssl.org/source/license.html
8
 */
9
10
#include <stdio.h>
11
#include <openssl/crypto.h>
12
#include "internal/cryptlib.h"
13
#include "internal/conf.h"
14
#include "conf_local.h"
15
#include <openssl/x509.h>
16
#include <openssl/asn1.h>
17
18
#if defined(_WIN32) && !defined(__BORLANDC__)
19
# define strdup _strdup
20
#endif
21
22
/*
23
 * This is the automatic configuration loader: it is called automatically by
24
 * OpenSSL when any of a number of standard initialisation functions are
25
 * called, unless this is overridden by calling OPENSSL_no_config()
26
 */
27
28
static int openssl_configured = 0;
29
30
#ifndef OPENSSL_NO_DEPRECATED_1_1_0
31
void OPENSSL_config(const char *appname)
32
0
{
33
0
    OPENSSL_INIT_SETTINGS settings;
34
35
0
    memset(&settings, 0, sizeof(settings));
36
0
    if (appname != NULL)
37
0
        settings.appname = strdup(appname);
38
0
    settings.flags = DEFAULT_CONF_MFLAGS;
39
0
    OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, &settings);
40
41
0
    free(settings.appname);
42
0
}
43
#endif
44
45
int ossl_config_int(const OPENSSL_INIT_SETTINGS *settings)
46
16
{
47
16
    int ret = 0;
48
16
#if defined(OPENSSL_INIT_DEBUG) || !defined(OPENSSL_SYS_UEFI)
49
16
    const char *filename;
50
16
    const char *appname;
51
16
    unsigned long flags;
52
16
#endif
53
54
16
    if (openssl_configured)
55
0
        return 1;
56
57
16
#if defined(OPENSSL_INIT_DEBUG) || !defined(OPENSSL_SYS_UEFI)
58
16
    filename = settings ? settings->filename : NULL;
59
16
    appname = settings ? settings->appname : NULL;
60
16
    flags = settings ? settings->flags : DEFAULT_CONF_MFLAGS;
61
16
#endif
62
63
#ifdef OPENSSL_INIT_DEBUG
64
    fprintf(stderr, "OPENSSL_INIT: ossl_config_int(%s, %s, %lu)\n",
65
            filename, appname, flags);
66
#endif
67
68
16
#ifndef OPENSSL_SYS_UEFI
69
16
    ret = CONF_modules_load_file_ex(OSSL_LIB_CTX_get0_global_default(),
70
16
                                    filename, appname, flags);
71
#else
72
    ret = 1;
73
#endif
74
16
    openssl_configured = 1;
75
16
    return ret;
76
16
}
77
78
void ossl_no_config_int(void)
79
0
{
80
0
    openssl_configured = 1;
81
0
}