Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 50f833d

Browse filesBrowse files
cjihrigtargos
authored andcommitted
net: report uv_tcp_open() errors
uv_tcp_open() can fail. Prior to this commit, any error was being silently ignored. This commit raises the errors. PR-URL: #21428 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 881d99b commit 50f833d
Copy full SHA for 50f833d

File tree

Expand file treeCollapse file tree

2 files changed

+19
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-5
lines changed
Open diff view settings
Collapse file

‎lib/net.js‎

Copy file name to clipboardExpand all lines: lib/net.js
+13-3Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,14 @@ function Socket(options) {
260260
this[async_id_symbol] = getNewAsyncId(this._handle);
261261
} else if (options.fd !== undefined) {
262262
const { fd } = options;
263+
let err;
264+
263265
this._handle = createHandle(fd, false);
264-
this._handle.open(fd);
266+
267+
err = this._handle.open(fd);
268+
if (err)
269+
throw errnoException(err, 'open');
270+
265271
this[async_id_symbol] = this._handle.getAsyncId();
266272
// options.fd can be string (since it is user-defined),
267273
// so changing this to === would be semver-major
@@ -271,7 +277,7 @@ function Socket(options) {
271277
(this._handle instanceof Pipe) &&
272278
process.platform === 'win32') {
273279
// Make stdout and stderr blocking on Windows
274-
var err = this._handle.setBlocking(true);
280+
err = this._handle.setBlocking(true);
275281
if (err)
276282
throw errnoException(err, 'setBlocking');
277283

@@ -1237,7 +1243,11 @@ function createServerHandle(address, port, addressType, fd) {
12371243
debug('listen invalid fd=%d:', fd, e.message);
12381244
return UV_EINVAL;
12391245
}
1240-
handle.open(fd);
1246+
1247+
err = handle.open(fd);
1248+
if (err)
1249+
return err;
1250+
12411251
handle.readable = true;
12421252
handle.writable = true;
12431253
assert(!address && !port);
Collapse file

‎src/tcp_wrap.cc‎

Copy file name to clipboardExpand all lines: src/tcp_wrap.cc
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,12 @@ void TCPWrap::Open(const FunctionCallbackInfo<Value>& args) {
211211
args.Holder(),
212212
args.GetReturnValue().Set(UV_EBADF));
213213
int fd = static_cast<int>(args[0]->IntegerValue());
214-
uv_tcp_open(&wrap->handle_, fd);
215-
wrap->set_fd(fd);
214+
int err = uv_tcp_open(&wrap->handle_, fd);
215+
216+
if (err == 0)
217+
wrap->set_fd(fd);
218+
219+
args.GetReturnValue().Set(err);
216220
}
217221

218222

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.