tls_wrap: do not abort on new TLSWrap()
Though the TLSWrap constructor is only called via TLSWrap::Wrap() (i.e. tls_wrap.wrap()) internally, it is still exposed to JS. Don't allow the application to abort by inspecting the instance before it has been wrap'd by another handle. PR-URL: https://github.com/nodejs/node/pull/6184 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
9dd5b93c42
commit
43b5215083
@ -888,7 +888,10 @@ void TLSWrap::Initialize(Local<Object> target,
|
||||
|
||||
env->SetMethod(target, "wrap", TLSWrap::Wrap);
|
||||
|
||||
Local<FunctionTemplate> t = FunctionTemplate::New(env->isolate());
|
||||
auto constructor = [](const FunctionCallbackInfo<Value>& args) {
|
||||
args.This()->SetAlignedPointerInInternalField(0, nullptr);
|
||||
};
|
||||
auto t = env->NewFunctionTemplate(constructor);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TLSWrap"));
|
||||
|
||||
|
8
test/parallel/test-tls-wrap-no-abort.js
Normal file
8
test/parallel/test-tls-wrap-no-abort.js
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
const util = require('util');
|
||||
const TLSWrap = process.binding('tls_wrap').TLSWrap;
|
||||
|
||||
// This will abort if internal pointer is not set to nullptr.
|
||||
util.inspect(new TLSWrap());
|
Loading…
x
Reference in New Issue
Block a user