Coverage Report

Created: 2025-07-01 06:26

/src/nss/lib/ssl/sslinit.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * NSS utility functions
3
 *
4
 * This Source Code Form is subject to the terms of the Mozilla Public
5
 * License, v. 2.0. If a copy of the MPL was not distributed with this
6
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
8
#include "prtypes.h"
9
#include "prinit.h"
10
#include "nss.h"
11
#include "seccomon.h"
12
#include "secerr.h"
13
#include "ssl.h"
14
#include "sslimpl.h"
15
#include "sslproto.h"
16
17
static PRCallOnceType ssl_init = { 0 };
18
PR_STATIC_ASSERT(sizeof(unsigned long) <= sizeof(PRUint64));
19
20
static SECStatus
21
ssl_InitShutdown(void *appData, void *nssData)
22
4
{
23
4
    memset(&ssl_init, 0, sizeof(ssl_init));
24
4
    return SECSuccess;
25
4
}
26
27
PRStatus
28
ssl_InitCallOnce(void *arg)
29
4
{
30
4
    int *error = (int *)arg;
31
4
    SECStatus rv;
32
33
4
    rv = ssl_InitializePRErrorTable();
34
4
    if (rv != SECSuccess) {
35
0
        *error = SEC_ERROR_NO_MEMORY;
36
0
        return PR_FAILURE;
37
0
    }
38
4
#ifdef DEBUG
39
4
    ssl3_CheckCipherSuiteOrderConsistency();
40
4
#endif
41
42
4
    rv = ssl3_ApplyNSSPolicy();
43
4
    if (rv != SECSuccess) {
44
0
        *error = PORT_GetError();
45
0
        return PR_FAILURE;
46
0
    }
47
48
4
    rv = NSS_RegisterShutdown(ssl_InitShutdown, NULL);
49
4
    if (rv != SECSuccess) {
50
0
        *error = PORT_GetError();
51
0
        return PR_FAILURE;
52
0
    }
53
4
    return PR_SUCCESS;
54
4
}
55
56
SECStatus
57
ssl_Init(void)
58
30.7k
{
59
30.7k
    int error;
60
30.7k
    PRStatus nrv = PR_CallOnceWithArg(&ssl_init, ssl_InitCallOnce, &error);
61
30.7k
    if (nrv != PR_SUCCESS) {
62
0
        PORT_SetError(error);
63
0
        return SECFailure;
64
0
    }
65
30.7k
    return SECSuccess;
66
30.7k
}