Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion src/crypto/crypto_keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,15 @@ MaybeLocal<Value> ToV8Value(
Environment* env,
const BIOPointer& bio,
const EVPKeyPointer::AsymmetricKeyEncodingConfig& config) {
if (!bio) return {};
if (!bio) {
THROW_ERR_CRYPTO_OPERATION_FAILED(env, "Invalid BIO pointer");
return {};
}
BUF_MEM* bptr = bio;
if (!bptr) {
THROW_ERR_CRYPTO_OPERATION_FAILED(env, "Unable to create BUF_MEM pointer");
return {};
}
if (config.format == EVPKeyPointer::PKFormatType::PEM) {
// PEM is an ASCII format, so we will return it as a string.
return String::NewFromUtf8(
Expand Down
6 changes: 6 additions & 0 deletions src/crypto/crypto_x509.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ MaybeLocal<Value> ToV8Value(Local<Context> context, BIOPointer&& bio) {
if (!bio) [[unlikely]]
return {};
BUF_MEM* mem = bio;
if (!mem) [[unlikely]]
return {};
Local<Value> ret;
if (!String::NewFromUtf8(Isolate::GetCurrent(),
mem->data,
Expand All @@ -120,6 +122,8 @@ MaybeLocal<Value> ToV8Value(Local<Context> context, const BIOPointer& bio) {
if (!bio) [[unlikely]]
return {};
BUF_MEM* mem = bio;
if (!mem) [[unlikely]]
return {};
Local<Value> ret;
if (!String::NewFromUtf8(Isolate::GetCurrent(),
mem->data,
Expand All @@ -134,6 +138,8 @@ MaybeLocal<Value> ToBuffer(Environment* env, BIOPointer* bio) {
if (bio == nullptr || !*bio) [[unlikely]]
return {};
BUF_MEM* mem = *bio;
if (!mem) [[unlikely]]
return {};
#ifdef V8_ENABLE_SANDBOX
// If the v8 sandbox is enabled, then all array buffers must be allocated
// via the isolate. External buffers are not allowed. So, instead of wrapping
Expand Down
Loading