crypto/rand: Fix a crash bug in RAND_enable_fork_unsafe_buffering.

Change-Id: Ifff59b1518f513c1be70e4e0d4ed3430741d0a5e
Reviewed-on: https://boringssl-review.googlesource.com/12860
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
This commit is contained in:
Martin Kreichgauer 2016-12-14 13:44:10 -08:00 committed by CQ bot account: commit-bot@chromium.org
parent 4cc1ccd3fc
commit 36ca21415a

View File

@ -207,13 +207,13 @@ void RAND_enable_fork_unsafe_buffering(int fd) {
abort(); // Already initialized
}
if (urandom_fd == kHaveGetrandom) {
if (fd >= 0) {
if (urandom_fd == kHaveGetrandom) {
close(fd);
}
} else if (urandom_fd != fd) {
abort(); // Already initialized.
}
}
}
static struct rand_buffer *get_thread_local_buffer(void) {