Coverage Report

Created: 2024-05-20 06:23

/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 "seccomon.h"
11
#include "secerr.h"
12
#include "ssl.h"
13
#include "sslimpl.h"
14
#include "sslproto.h"
15
16
static int ssl_isInited = 0;
17
static PRCallOnceType ssl_init = { 0 };
18
PR_STATIC_ASSERT(sizeof(unsigned long) <= sizeof(PRUint64));
19
20
PRStatus
21
ssl_InitCallOnce(void *arg)
22
1
{
23
1
    int *error = (int *)arg;
24
1
    SECStatus rv;
25
26
1
    rv = ssl_InitializePRErrorTable();
27
1
    if (rv != SECSuccess) {
28
0
        *error = SEC_ERROR_NO_MEMORY;
29
0
        return PR_FAILURE;
30
0
    }
31
1
#ifdef DEBUG
32
1
    ssl3_CheckCipherSuiteOrderConsistency();
33
1
#endif
34
35
1
    rv = ssl3_ApplyNSSPolicy();
36
1
    if (rv != SECSuccess) {
37
0
        *error = PORT_GetError();
38
0
        return PR_FAILURE;
39
0
    }
40
1
    return PR_SUCCESS;
41
1
}
42
43
SECStatus
44
ssl_Init(void)
45
8.40k
{
46
8.40k
    PRStatus nrv;
47
48
    /* short circuit test if we are already inited */
49
8.40k
    if (!ssl_isInited) {
50
1
        int error;
51
        /* only do this once at init time, block all others until we are done */
52
1
        nrv = PR_CallOnceWithArg(&ssl_init, ssl_InitCallOnce, &error);
53
1
        if (nrv != PR_SUCCESS) {
54
0
            PORT_SetError(error);
55
0
            return SECFailure;
56
0
        }
57
1
        ssl_isInited = 1;
58
1
    }
59
8.40k
    return SECSuccess;
60
8.40k
}