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 a1831da

Browse filesBrowse files
deokjinkimdanielleadams
authored andcommitted
net: check autoSelectFamilyAttemptTimeout is positive
In document, `autoSelectFamilyAttemptTimeout` is described as positive integer because it's time unit. But there is no checking whether it's positive integer. PR-URL: #45740 Refs: https://github.com/nodejs/node/blob/main/doc/api/net.md#socketconnectoptions-connectlistener Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent c116253 commit a1831da
Copy full SHA for a1831da

File tree

Expand file treeCollapse file tree

2 files changed

+15
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-1
lines changed
Open diff view settings
Collapse file

‎lib/net.js‎

Copy file name to clipboardExpand all lines: lib/net.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ function lookupAndConnect(self, options) {
12261226
}
12271227

12281228
if (autoSelectFamilyAttemptTimeout !== undefined) {
1229-
validateInt32(autoSelectFamilyAttemptTimeout);
1229+
validateInt32(autoSelectFamilyAttemptTimeout, 'options.autoSelectFamilyAttemptTimeout', 1);
12301230

12311231
if (autoSelectFamilyAttemptTimeout < 10) {
12321232
autoSelectFamilyAttemptTimeout = 10;
Collapse file
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
const net = require('net');
5+
6+
for (const autoSelectFamilyAttemptTimeout of [-10, 0]) {
7+
assert.throws(() => {
8+
net.connect({
9+
port: 8080,
10+
autoSelectFamily: true,
11+
autoSelectFamilyAttemptTimeout,
12+
});
13+
}, { code: 'ERR_OUT_OF_RANGE' });
14+
}

0 commit comments

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