Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rand_fork_unsafe_buffering_enabled always 0 on Windows #1528

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions crypto/rand_extra/forkunsafe.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
#include "../fipsmodule/rand/internal.h"


#if !defined(OPENSSL_WINDOWS)
// g_buffering_enabled is true if fork-unsafe buffering has been enabled.
static int g_buffering_enabled = 0;

// g_lock protects |g_buffering_enabled|.
static struct CRYPTO_STATIC_MUTEX g_lock = CRYPTO_STATIC_MUTEX_INIT;

#if !defined(OPENSSL_WINDOWS)
void RAND_enable_fork_unsafe_buffering(int fd) {
// We no longer support setting the file-descriptor with this function.
if (fd != -1) {
Expand All @@ -36,11 +36,15 @@ void RAND_enable_fork_unsafe_buffering(int fd) {
g_buffering_enabled = 1;
CRYPTO_STATIC_MUTEX_unlock_write(&g_lock);
}
#endif

int rand_fork_unsafe_buffering_enabled(void) {
CRYPTO_STATIC_MUTEX_lock_read(&g_lock);
const int ret = g_buffering_enabled;
CRYPTO_STATIC_MUTEX_unlock_read(&g_lock);
return ret;
}
#else
int rand_fork_unsafe_buffering_enabled(void) {
return 0;
}
#endif
Loading