From c0e6c668e6e6f0ba6a924a5b83ff1ca5434d14ad Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Wed, 13 Apr 2016 13:16:42 -0600 Subject: 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 Reviewed-By: Anna Henningsen --- src/tty_wrap.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/tty_wrap.cc') diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc index 6e91dbcd74..319a74fd36 100644 --- a/src/tty_wrap.cc +++ b/src/tty_wrap.cc @@ -90,7 +90,10 @@ void TTYWrap::IsTTY(const FunctionCallbackInfo& args) { void TTYWrap::GetWindowSize(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - TTYWrap* wrap = Unwrap(args.Holder()); + TTYWrap* wrap; + ASSIGN_OR_RETURN_UNWRAP(&wrap, + args.Holder(), + args.GetReturnValue().Set(UV_EBADF)); CHECK(args[0]->IsArray()); int width, height; @@ -107,7 +110,10 @@ void TTYWrap::GetWindowSize(const FunctionCallbackInfo& args) { void TTYWrap::SetRawMode(const FunctionCallbackInfo& args) { - TTYWrap* wrap = Unwrap(args.Holder()); + TTYWrap* wrap; + ASSIGN_OR_RETURN_UNWRAP(&wrap, + args.Holder(), + args.GetReturnValue().Set(UV_EBADF)); int err = uv_tty_set_mode(&wrap->handle_, args[0]->IsTrue()); args.GetReturnValue().Set(err); } -- cgit v1.2.3