Skip to content

Commit 703bc10

Browse files
committed
permission: add kNet check to Open() in TCPWrap/PipeWrap/UDPWrap
1 parent 4241d0d commit 703bc10

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/pipe_wrap.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ void PipeWrap::Open(const FunctionCallbackInfo<Value>& args) {
211211
int fd;
212212
if (!args[0]->Int32Value(env->context()).To(&fd)) return;
213213

214+
THROW_IF_INSUFFICIENT_PERMISSIONS(env, permission::PermissionScope::kNet, "");
215+
214216
int err = uv_pipe_open(&wrap->handle_, fd);
215217
if (err == 0) wrap->set_fd(fd);
216218

src/tcp_wrap.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ void TCPWrap::Open(const FunctionCallbackInfo<Value>& args) {
361361
TCPWrap* wrap;
362362
ASSIGN_OR_RETURN_UNWRAP(
363363
&wrap, args.This(), args.GetReturnValue().Set(UV_EBADF));
364+
Environment* env = wrap->env();
365+
366+
THROW_IF_INSUFFICIENT_PERMISSIONS(env, permission::PermissionScope::kNet, "");
367+
364368
int64_t val;
365369
if (!args[0]->IntegerValue(args.GetIsolate()->GetCurrentContext()).To(&val))
366370
return;

src/udp_wrap.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ void UDPWrap::Open(const FunctionCallbackInfo<Value>& args) {
368368
UDPWrap* wrap;
369369
ASSIGN_OR_RETURN_UNWRAP(
370370
&wrap, args.This(), args.GetReturnValue().Set(UV_EBADF));
371+
Environment* env = wrap->env();
372+
373+
THROW_IF_INSUFFICIENT_PERMISSIONS(env, permission::PermissionScope::kNet, "");
374+
371375
CHECK(args[0]->IsNumber());
372376
int fd = FromV8Value<int>(args[0]);
373377
int err = uv_udp_open(&wrap->handle_, fd);

0 commit comments

Comments
 (0)