Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2016-04-13 22:16:42 +0300
committerTrevor Norris <trev.norris@gmail.com>2016-05-24 23:40:22 +0300
commitc0e6c668e6e6f0ba6a924a5b83ff1ca5434d14ad (patch)
tree2f24e1329abb6b5432273246b4754ec44e7b3e8a /src/pipe_wrap.cc
parent13e5d4f32014e3426142580a699d0ffdf02db26a (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/pipe_wrap.cc')
-rw-r--r--src/pipe_wrap.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc
index 7be07de74b2..286ea30a87c 100644
--- a/src/pipe_wrap.cc
+++ b/src/pipe_wrap.cc
@@ -138,7 +138,8 @@ PipeWrap::PipeWrap(Environment* env,
void PipeWrap::Bind(const FunctionCallbackInfo<Value>& args) {
- PipeWrap* wrap = Unwrap<PipeWrap>(args.Holder());
+ PipeWrap* wrap;
+ ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
node::Utf8Value name(args.GetIsolate(), args[0]);
int err = uv_pipe_bind(&wrap->handle_, *name);
args.GetReturnValue().Set(err);
@@ -147,7 +148,8 @@ void PipeWrap::Bind(const FunctionCallbackInfo<Value>& args) {
#ifdef _WIN32
void PipeWrap::SetPendingInstances(const FunctionCallbackInfo<Value>& args) {
- PipeWrap* wrap = Unwrap<PipeWrap>(args.Holder());
+ PipeWrap* wrap;
+ ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
int instances = args[0]->Int32Value();
uv_pipe_pending_instances(&wrap->handle_, instances);
}
@@ -155,7 +157,8 @@ void PipeWrap::SetPendingInstances(const FunctionCallbackInfo<Value>& args) {
void PipeWrap::Listen(const FunctionCallbackInfo<Value>& args) {
- PipeWrap* wrap = Unwrap<PipeWrap>(args.Holder());
+ PipeWrap* wrap;
+ ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
int backlog = args[0]->Int32Value();
int err = uv_listen(reinterpret_cast<uv_stream_t*>(&wrap->handle_),
backlog,
@@ -191,7 +194,8 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
Local<Object> client_obj = Instantiate(env, pipe_wrap);
// Unwrap the client javascript object.
- PipeWrap* wrap = Unwrap<PipeWrap>(client_obj);
+ PipeWrap* wrap;
+ ASSIGN_OR_RETURN_UNWRAP(&wrap, client_obj);
uv_stream_t* client_handle = reinterpret_cast<uv_stream_t*>(&wrap->handle_);
if (uv_accept(handle, client_handle))
return;
@@ -242,7 +246,8 @@ void PipeWrap::AfterConnect(uv_connect_t* req, int status) {
void PipeWrap::Open(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
- PipeWrap* wrap = Unwrap<PipeWrap>(args.Holder());
+ PipeWrap* wrap;
+ ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
int fd = args[0]->Int32Value();
@@ -256,7 +261,8 @@ void PipeWrap::Open(const FunctionCallbackInfo<Value>& args) {
void PipeWrap::Connect(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
- PipeWrap* wrap = Unwrap<PipeWrap>(args.Holder());
+ PipeWrap* wrap;
+ ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
CHECK(args[0]->IsObject());
CHECK(args[1]->IsString());