diff options
author | Trevor Norris <trev.norris@gmail.com> | 2016-04-13 22:16:42 +0300 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2016-05-24 23:40:22 +0300 |
commit | c0e6c668e6e6f0ba6a924a5b83ff1ca5434d14ad (patch) | |
tree | 2f24e1329abb6b5432273246b4754ec44e7b3e8a /src/process_wrap.cc | |
parent | 13e5d4f32014e3426142580a699d0ffdf02db26a (diff) |
src: no abort from getter if object isn't wrapped
v8::Object::GetAlignedPointerFromInternalField() returns a random value
if Wrap() hasn't been run on the object handle. Causing v8 to abort if
certain getters are accessed. It's possible to access these getters and
functions during class construction through the AsyncWrap init()
callback, and also possible in a subset of those scenarios while running
the persistent handle visitor.
Mitigate this issue by manually setting the internal aligned pointer
field to nullptr in the BaseObject constructor and add necessary logic
to return appropriate values when nullptr is encountered.
PR-URL: https://github.com/nodejs/node/pull/6184
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/process_wrap.cc')
-rw-r--r-- | src/process_wrap.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 36c6cfe3adb..2b214d1d47a 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -86,6 +86,7 @@ class ProcessWrap : public HandleWrap { UV_CREATE_PIPE | UV_READABLE_PIPE | UV_WRITABLE_PIPE); Local<String> handle_key = env->handle_string(); Local<Object> handle = stdio->Get(handle_key).As<Object>(); + CHECK(!handle.IsEmpty()); options->stdio[i].data.stream = reinterpret_cast<uv_stream_t*>( Unwrap<PipeWrap>(handle)->UVHandle()); @@ -109,7 +110,8 @@ class ProcessWrap : public HandleWrap { static void Spawn(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); - ProcessWrap* wrap = Unwrap<ProcessWrap>(args.Holder()); + ProcessWrap* wrap; + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); Local<Object> js_options = args[0]->ToObject(env->isolate()); @@ -233,7 +235,8 @@ class ProcessWrap : public HandleWrap { } static void Kill(const FunctionCallbackInfo<Value>& args) { - ProcessWrap* wrap = Unwrap<ProcessWrap>(args.Holder()); + ProcessWrap* wrap; + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); int signal = args[0]->Int32Value(); int err = uv_process_kill(&wrap->process_, signal); args.GetReturnValue().Set(err); |