★ wanayoo — archive 1999 https://github.com/nodejs/node/commit/b2ac7a750fNouvelle recherche | Portail wanayoo
Skip to content
Permalink
Browse files

src: avoid possible race during NodeBIO initialization

PR-URL: #21984
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
addaleax authored and rvagg committed Jul 26, 2018
1 parent d85b0a3 commit b2ac7a750f9d3ec91a5fe30f47da5aa4d6978c51
Showing with 8 additions and 0 deletions.
  1. +2 −0 src/node_crypto.cc
  2. +2 −0 src/node_crypto.h
  3. +2 −0 src/node_crypto_bio.cc
  4. +2 −0 src/node_crypto_bio.h
@@ -5126,6 +5126,8 @@ void InitCryptoOnce() {
ERR_load_ENGINE_strings();
ENGINE_load_builtin_engines();
#endif // !OPENSSL_NO_ENGINE

NodeBIO::GetMethod();
}


@@ -97,6 +97,8 @@ extern int VerifyCallback(int preverify_ok, X509_STORE_CTX* ctx);

extern void UseExtraCaCerts(const std::string& file);

void InitCryptoOnce();

class SecureContext : public BaseObject {
public:
~SecureContext() override {
@@ -247,6 +247,8 @@ const BIO_METHOD* NodeBIO::GetMethod() {

return &method;
#else
// This is called from InitCryptoOnce() to avoid race conditions during
// initialization.
static BIO_METHOD* method = nullptr;

if (method == nullptr) {
@@ -164,6 +164,8 @@ class NodeBIO : public MemoryRetainer {
int eof_return_ = -1;
Buffer* read_head_ = nullptr;
Buffer* write_head_ = nullptr;

friend void node::crypto::InitCryptoOnce();
};

} // namespace crypto

0 comments on commit b2ac7a7

Please sign in to comment.
You can’t perform that action at this time.