forkunsafe.c
Go to the documentation of this file.
1 /* Copyright (c) 2017, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #include <openssl/rand.h>
16 
17 #include <stdlib.h>
18 
19 #include "../fipsmodule/rand/internal.h"
20 
21 
22 // g_buffering_enabled is true if fork-unsafe buffering has been enabled.
23 static int g_buffering_enabled = 0;
24 
25 // g_lock protects |g_buffering_enabled|.
27 
28 #if !defined(OPENSSL_WINDOWS)
30  // We no longer support setting the file-descriptor with this function.
31  if (fd != -1) {
32  abort();
33  }
34 
38 }
39 #endif
40 
43  const int ret = g_buffering_enabled;
45  return ret;
46 }
CRYPTO_STATIC_MUTEX_INIT
#define CRYPTO_STATIC_MUTEX_INIT
Definition: third_party/boringssl-with-bazel/src/crypto/internal.h:536
rand_fork_unsafe_buffering_enabled
int rand_fork_unsafe_buffering_enabled(void)
Definition: forkunsafe.c:41
CRYPTO_STATIC_MUTEX_unlock_write
#define CRYPTO_STATIC_MUTEX_unlock_write
Definition: boringssl_prefix_symbols.h:1135
CRYPTO_STATIC_MUTEX
Definition: third_party/boringssl-with-bazel/src/crypto/internal.h:533
CRYPTO_STATIC_MUTEX_unlock_read
#define CRYPTO_STATIC_MUTEX_unlock_read
Definition: boringssl_prefix_symbols.h:1134
CRYPTO_STATIC_MUTEX_lock_write
#define CRYPTO_STATIC_MUTEX_lock_write
Definition: boringssl_prefix_symbols.h:1133
g_buffering_enabled
static int g_buffering_enabled
Definition: forkunsafe.c:23
g_lock
static struct CRYPTO_STATIC_MUTEX g_lock
Definition: forkunsafe.c:26
rand.h
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
CRYPTO_STATIC_MUTEX_lock_read
#define CRYPTO_STATIC_MUTEX_lock_read
Definition: boringssl_prefix_symbols.h:1132
RAND_enable_fork_unsafe_buffering
void RAND_enable_fork_unsafe_buffering(int fd)
Definition: forkunsafe.c:29


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:22