diff options
author | Fedor Indutny <fedor@indutny.com> | 2019-11-26 23:47:00 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-02-06 17:22:50 +0300 |
commit | 861d3f7a61f543c253337cfc1a967fa84f96c653 (patch) | |
tree | 30ea699e579292e232a44bba01ddaab06bdc3b4d /src/node_crypto.cc | |
parent | fe3975783cc4fdba47c2e25442ca891aab31e805 (diff) |
crypto: fix assertion caused by unsupported ext
`X509V3_EXT_print` can return value different from `1` if the X509
extension does not support printing to a buffer. Instead of failing with
an unrecoverable assertion - replace the relevant value in the hashmap
with a JS null value.
Fixes: https://hackerone.com/reports/746733
PR-URL: https://github.com/nodejs-private/node-private/pull/175
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'src/node_crypto.cc')
-rw-r--r-- | src/node_crypto.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 459f5479ac4..92760fb8c85 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1995,8 +1995,11 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) { X509_EXTENSION* ext = X509_get_ext(cert, index); CHECK_NOT_NULL(ext); - if (!SafeX509ExtPrint(bio.get(), ext)) { - CHECK_EQ(1, X509V3_EXT_print(bio.get(), ext, 0, 0)); + if (!SafeX509ExtPrint(bio.get(), ext) && + X509V3_EXT_print(bio.get(), ext, 0, 0) != 1) { + info->Set(context, keys[i], Null(env->isolate())).Check(); + USE(BIO_reset(bio.get())); + continue; } BIO_get_mem_ptr(bio.get(), &mem); |