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 1d14886

Browse filesBrowse files
theanarkhmarco-ippolito
authored andcommitted
dgram: check udp buffer size to avoid fd leak
PR-URL: #56084 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e464c6f commit 1d14886
Copy full SHA for 1d14886

File tree

2 files changed

+20
-0
lines changed
Filter options

2 files changed

+20
-0
lines changed

‎lib/dgram.js

Copy file name to clipboardExpand all lines: lib/dgram.js
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const {
5656
validateString,
5757
validateNumber,
5858
validatePort,
59+
validateUint32,
5960
} = require('internal/validators');
6061
const { Buffer } = require('buffer');
6162
const { deprecate, guessHandleType, promisify, SymbolAsyncDispose, SymbolDispose } = require('internal/util');
@@ -111,6 +112,12 @@ function Socket(type, listener) {
111112
options = type;
112113
type = options.type;
113114
lookup = options.lookup;
115+
if (options.recvBufferSize) {
116+
validateUint32(options.recvBufferSize, 'options.recvBufferSize');
117+
}
118+
if (options.sendBufferSize) {
119+
validateUint32(options.sendBufferSize, 'options.sendBufferSize');
120+
}
114121
recvBufferSize = options.recvBufferSize;
115122
sendBufferSize = options.sendBufferSize;
116123
}

‎test/parallel/test-dgram-createSocket-type.js

Copy file name to clipboardExpand all lines: test/parallel/test-dgram-createSocket-type.js
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,16 @@ validTypes.forEach((validType) => {
5959
socket.close();
6060
}));
6161
}
62+
63+
{
64+
[
65+
{ type: 'udp4', recvBufferSize: 'invalid' },
66+
{ type: 'udp4', sendBufferSize: 'invalid' },
67+
].forEach((options) => {
68+
assert.throws(() => {
69+
dgram.createSocket(options);
70+
}, {
71+
code: 'ERR_INVALID_ARG_TYPE',
72+
});
73+
});
74+
}

0 commit comments

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