summaryrefslogtreecommitdiff
path: root/src/node_zlib.cc
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2016-04-13 13:16:42 -0600
committerTrevor Norris <trev.norris@gmail.com>2016-05-24 14:40:22 -0600
commitc0e6c668e6e6f0ba6a924a5b83ff1ca5434d14ad (patch)
tree2f24e1329abb6b5432273246b4754ec44e7b3e8a /src/node_zlib.cc
parent13e5d4f32014e3426142580a699d0ffdf02db26a (diff)
downloadandroid-node-v8-c0e6c668e6e6f0ba6a924a5b83ff1ca5434d14ad.tar.gz
android-node-v8-c0e6c668e6e6f0ba6a924a5b83ff1ca5434d14ad.tar.bz2
android-node-v8-c0e6c668e6e6f0ba6a924a5b83ff1ca5434d14ad.zip
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/node_zlib.cc')
-rw-r--r--src/node_zlib.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/node_zlib.cc b/src/node_zlib.cc
index aee1cbae95..4de9d7cdc2 100644
--- a/src/node_zlib.cc
+++ b/src/node_zlib.cc
@@ -109,7 +109,8 @@ class ZCtx : public AsyncWrap {
static void Close(const FunctionCallbackInfo<Value>& args) {
- ZCtx* ctx = Unwrap<ZCtx>(args.Holder());
+ ZCtx* ctx;
+ ASSIGN_OR_RETURN_UNWRAP(&ctx, args.Holder());
ctx->Close();
}
@@ -119,7 +120,8 @@ class ZCtx : public AsyncWrap {
static void Write(const FunctionCallbackInfo<Value>& args) {
CHECK_EQ(args.Length(), 7);
- ZCtx* ctx = Unwrap<ZCtx>(args.Holder());
+ ZCtx* ctx;
+ ASSIGN_OR_RETURN_UNWRAP(&ctx, args.Holder());
CHECK(ctx->init_done_ && "write before init");
CHECK(ctx->mode_ != NONE && "already finalized");
@@ -431,7 +433,8 @@ class ZCtx : public AsyncWrap {
CHECK((args.Length() == 4 || args.Length() == 5) &&
"init(windowBits, level, memLevel, strategy, [dictionary])");
- ZCtx* ctx = Unwrap<ZCtx>(args.Holder());
+ ZCtx* ctx;
+ ASSIGN_OR_RETURN_UNWRAP(&ctx, args.Holder());
int windowBits = args[0]->Uint32Value();
CHECK((windowBits >= 8 && windowBits <= 15) && "invalid windowBits");
@@ -467,12 +470,14 @@ class ZCtx : public AsyncWrap {
static void Params(const FunctionCallbackInfo<Value>& args) {
CHECK(args.Length() == 2 && "params(level, strategy)");
- ZCtx* ctx = Unwrap<ZCtx>(args.Holder());
+ ZCtx* ctx;
+ ASSIGN_OR_RETURN_UNWRAP(&ctx, args.Holder());
Params(ctx, args[0]->Int32Value(), args[1]->Int32Value());
}
static void Reset(const FunctionCallbackInfo<Value> &args) {
- ZCtx* ctx = Unwrap<ZCtx>(args.Holder());
+ ZCtx* ctx;
+ ASSIGN_OR_RETURN_UNWRAP(&ctx, args.Holder());
Reset(ctx);
SetDictionary(ctx);
}