Skip to content

Commit b9c2fc7

Browse files
deokjinkimtargos
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 4c51c5c commit b9c2fc7

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/net.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ function lookupAndConnect(self, options) {
12101210
}
12111211

12121212
if (autoSelectFamilyAttemptTimeout !== undefined) {
1213-
validateInt32(autoSelectFamilyAttemptTimeout);
1213+
validateInt32(autoSelectFamilyAttemptTimeout, 'options.autoSelectFamilyAttemptTimeout', 1);
12141214

12151215
if (autoSelectFamilyAttemptTimeout < 10) {
12161216
autoSelectFamilyAttemptTimeout = 10;
Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy