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 7ddbf94

Browse filesBrowse files
theanarkhruyadorno
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 4559fac commit 7ddbf94
Copy full SHA for 7ddbf94

File tree

Expand file treeCollapse file tree

2 files changed

+20
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+20
-0
lines changed
Open diff view settings
Collapse file

‎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
@@ -59,6 +59,7 @@ const {
5959
validateString,
6060
validateNumber,
6161
validatePort,
62+
validateUint32,
6263
} = require('internal/validators');
6364
const { Buffer } = require('buffer');
6465
const { deprecate, guessHandleType, promisify, SymbolAsyncDispose, SymbolDispose } = require('internal/util');
@@ -108,6 +109,12 @@ function Socket(type, listener) {
108109
options = type;
109110
type = options.type;
110111
lookup = options.lookup;
112+
if (options.recvBufferSize) {
113+
validateUint32(options.recvBufferSize, 'options.recvBufferSize');
114+
}
115+
if (options.sendBufferSize) {
116+
validateUint32(options.sendBufferSize, 'options.sendBufferSize');
117+
}
111118
recvBufferSize = options.recvBufferSize;
112119
sendBufferSize = options.sendBufferSize;
113120
}
Collapse file

‎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.