mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
dgram: check udp buffer size to avoid fd leak
PR-URL: https://github.com/nodejs/node/pull/56084 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
@@ -61,6 +61,7 @@ const {
|
||||
validateString,
|
||||
validateNumber,
|
||||
validatePort,
|
||||
validateUint32,
|
||||
} = require('internal/validators');
|
||||
const { Buffer } = require('buffer');
|
||||
const { deprecate, guessHandleType, promisify } = require('internal/util');
|
||||
@@ -110,6 +111,12 @@ function Socket(type, listener) {
|
||||
options = type;
|
||||
type = options.type;
|
||||
lookup = options.lookup;
|
||||
if (options.recvBufferSize) {
|
||||
validateUint32(options.recvBufferSize, 'options.recvBufferSize');
|
||||
}
|
||||
if (options.sendBufferSize) {
|
||||
validateUint32(options.sendBufferSize, 'options.sendBufferSize');
|
||||
}
|
||||
recvBufferSize = options.recvBufferSize;
|
||||
sendBufferSize = options.sendBufferSize;
|
||||
}
|
||||
|
||||
@@ -59,3 +59,16 @@ validTypes.forEach((validType) => {
|
||||
socket.close();
|
||||
}));
|
||||
}
|
||||
|
||||
{
|
||||
[
|
||||
{ type: 'udp4', recvBufferSize: 'invalid' },
|
||||
{ type: 'udp4', sendBufferSize: 'invalid' },
|
||||
].forEach((options) => {
|
||||
assert.throws(() => {
|
||||
dgram.createSocket(options);
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user