Coverage Report

Created: 2025-08-28 06:59

/src/boringssl/crypto/rand/forkunsafe.cc
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2017 The BoringSSL Authors
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include <openssl/rand.h>
16
17
#include <stdlib.h>
18
19
#include "../fipsmodule/rand/internal.h"
20
#include "../internal.h"
21
22
23
// g_buffering_enabled is one if fork-unsafe buffering has been enabled and zero
24
// otherwise.
25
static CRYPTO_atomic_u32 g_buffering_enabled;
26
27
#if !defined(OPENSSL_WINDOWS)
28
0
void RAND_enable_fork_unsafe_buffering(int fd) {
29
  // We no longer support setting the file-descriptor with this function.
30
0
  if (fd != -1) {
31
0
    abort();
32
0
  }
33
34
0
  CRYPTO_atomic_store_u32(&g_buffering_enabled, 1);
35
0
}
36
37
0
void RAND_disable_fork_unsafe_buffering(void) {
38
0
  CRYPTO_atomic_store_u32(&g_buffering_enabled, 0);
39
0
}
40
#endif
41
42
628k
int rand_fork_unsafe_buffering_enabled(void) {
43
628k
  return CRYPTO_atomic_load_u32(&g_buffering_enabled) != 0;
44
628k
}