File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ const {
75
75
ERR_SOCKET_BAD_PORT ,
76
76
ERR_SOCKET_CLOSED
77
77
} = errors . codes ;
78
-
78
+ const { validateInt32 } = require ( 'internal/validators' ) ;
79
79
const kLastWriteQueueSize = Symbol ( 'lastWriteQueueSize' ) ;
80
80
81
81
// Lazy loaded to improve startup performance.
@@ -93,6 +93,7 @@ const {
93
93
function noop ( ) { }
94
94
95
95
function createHandle ( fd , is_server ) {
96
+ validateInt32 ( fd , 'fd' , 0 ) ;
96
97
const type = TTYWrap . guessHandleType ( fd ) ;
97
98
if ( type === 'PIPE' ) {
98
99
return new Pipe (
Original file line number Diff line number Diff line change @@ -4,6 +4,14 @@ const common = require('../common');
4
4
const assert = require ( 'assert' ) ;
5
5
const net = require ( 'net' ) ;
6
6
7
+ common . expectsError ( ( ) => {
8
+ new net . Socket ( { fd : - 1 } ) ;
9
+ } , { code : 'ERR_OUT_OF_RANGE' } ) ;
10
+
11
+ common . expectsError ( ( ) => {
12
+ new net . Socket ( { fd : 'foo' } ) ;
13
+ } , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
14
+
7
15
function test ( sock , readable , writable ) {
8
16
let socket ;
9
17
if ( sock instanceof net . Socket ) {
You can’t perform that action at this time.
0 commit comments