Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! zlib
  • Loading branch information
targos committed Sep 2, 2018
commit 0bf15c510e2c7641e0046a4d094ca5fe7bfd5247
21 changes: 12 additions & 9 deletions src/node_zlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork {

CHECK_EQ(false, args[0]->IsUndefined() && "must provide flush value");

unsigned int flush = args[0].As<Uint32>()->Value();
Environment* env = ctx->env();
Local<Context> context = env->context();

unsigned int flush;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess CI is going to tell us whether it’s a real problem, but at least in theory this would be uint32_t, too

if (!args[0]->Uint32Value(context).To(&flush)) return;

if (flush != Z_NO_FLUSH &&
flush != Z_PARTIAL_FLUSH &&
Expand All @@ -171,8 +175,7 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork {

Bytef* in;
Bytef* out;
size_t in_off, in_len, out_off, out_len;
Environment* env = ctx->env();
uint32_t in_off, in_len, out_off, out_len;

if (args[1]->IsNull()) {
// just a flush
Expand All @@ -182,18 +185,18 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork {
} else {
CHECK(Buffer::HasInstance(args[1]));
Local<Object> in_buf;
in_buf = args[1]->ToObject(env->context()).ToLocalChecked();
in_off = args[2].As<Uint32>()->Value();
in_len = args[3].As<Uint32>()->Value();
in_buf = args[1]->ToObject(context).ToLocalChecked();
if (!args[2]->Uint32Value(context).To(&in_off)) return;
if (!args[3]->Uint32Value(context).To(&in_len)) return;

CHECK(Buffer::IsWithinBounds(in_off, in_len, Buffer::Length(in_buf)));
in = reinterpret_cast<Bytef *>(Buffer::Data(in_buf) + in_off);
}

CHECK(Buffer::HasInstance(args[4]));
Local<Object> out_buf = args[4]->ToObject(env->context()).ToLocalChecked();
in_off = args[2].As<Uint32>()->Value();
in_len = args[3].As<Uint32>()->Value();
Local<Object> out_buf = args[4]->ToObject(context).ToLocalChecked();
if (!args[5]->Uint32Value(context).To(&out_off)) return;
if (!args[6]->Uint32Value(context).To(&out_len)) return;
CHECK(Buffer::IsWithinBounds(out_off, out_len, Buffer::Length(out_buf)));
out = reinterpret_cast<Bytef *>(Buffer::Data(out_buf) + out_off);

Expand Down