From b838baf08823d420eee88f72f2b82f89e08ea998 Mon Sep 17 00:00:00 2001 From: "Bruce A. MacNaughton" Date: Fri, 12 Oct 2018 09:07:46 -0700 Subject: [PATCH 1/3] src: change v8:ConstructorBehavior in stream_base-inl.h Throw if addMethod functions used as constructors. --- src/stream_base-inl.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h index 027b938d30df1c..0209281f942e1c 100644 --- a/src/stream_base-inl.h +++ b/src/stream_base-inl.h @@ -275,29 +275,28 @@ void StreamBase::AddMethods(Environment* env, Local t) { Local signature = Signature::New(env->isolate(), t); - // TODO(TimothyGu): None of these should have ConstructorBehavior::kAllow. Local get_fd_templ = env->NewFunctionTemplate(GetFD, signature, - v8::ConstructorBehavior::kAllow, + v8::ConstructorBehavior::kThrow, v8::SideEffectType::kHasNoSideEffect); Local get_external_templ = env->NewFunctionTemplate(GetExternal, signature, - v8::ConstructorBehavior::kAllow, + v8::ConstructorBehavior::kThrow, v8::SideEffectType::kHasNoSideEffect); Local get_bytes_read_templ = env->NewFunctionTemplate(GetBytesRead, signature, - v8::ConstructorBehavior::kAllow, + v8::ConstructorBehavior::kThrow, v8::SideEffectType::kHasNoSideEffect); Local get_bytes_written_templ = env->NewFunctionTemplate(GetBytesWritten, signature, - v8::ConstructorBehavior::kAllow, + v8::ConstructorBehavior::kThrow, v8::SideEffectType::kHasNoSideEffect); t->PrototypeTemplate()->SetAccessorProperty(env->fd_string(), From f8087e67eadd30e30613939f7be9e555b0a879b3 Mon Sep 17 00:00:00 2001 From: "Bruce A. MacNaughton" Date: Fri, 12 Oct 2018 11:03:51 -0700 Subject: [PATCH 2/3] src: throw if functions used as constructors in node_crypto.cc Throw an error if verify_error_getter_templ or verify_error_getter_templ2 are used as constructors. --- src/node_crypto.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 9b22edfb9605e6..e41897b5d33635 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -3919,8 +3919,7 @@ void DiffieHellman::Initialize(Environment* env, Local target) { env->as_external(), Signature::New(env->isolate(), t), /* length */ 0, - // TODO(TimothyGu): should be deny - ConstructorBehavior::kAllow, + ConstructorBehavior::kThrow, SideEffectType::kHasNoSideEffect); t->InstanceTemplate()->SetAccessorProperty( @@ -3948,8 +3947,7 @@ void DiffieHellman::Initialize(Environment* env, Local target) { env->as_external(), Signature::New(env->isolate(), t2), /* length */ 0, - // TODO(TimothyGu): should be deny - ConstructorBehavior::kAllow, + ConstructorBehavior::kThrow, SideEffectType::kHasNoSideEffect); t2->InstanceTemplate()->SetAccessorProperty( From 63b6f910549a7a117fe3894f649d26ca0202c7b9 Mon Sep 17 00:00:00 2001 From: "Bruce A. MacNaughton" Date: Fri, 12 Oct 2018 11:12:15 -0700 Subject: [PATCH 3/3] Revert "src: throw if functions used as constructors in node_crypto.cc" This reverts commit f8087e67eadd30e30613939f7be9e555b0a879b3. --- src/node_crypto.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index e41897b5d33635..9b22edfb9605e6 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -3919,7 +3919,8 @@ void DiffieHellman::Initialize(Environment* env, Local target) { env->as_external(), Signature::New(env->isolate(), t), /* length */ 0, - ConstructorBehavior::kThrow, + // TODO(TimothyGu): should be deny + ConstructorBehavior::kAllow, SideEffectType::kHasNoSideEffect); t->InstanceTemplate()->SetAccessorProperty( @@ -3947,7 +3948,8 @@ void DiffieHellman::Initialize(Environment* env, Local target) { env->as_external(), Signature::New(env->isolate(), t2), /* length */ 0, - ConstructorBehavior::kThrow, + // TODO(TimothyGu): should be deny + ConstructorBehavior::kAllow, SideEffectType::kHasNoSideEffect); t2->InstanceTemplate()->SetAccessorProperty(