GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — dgram: check udp buffer size to avoid fd leak · nodejs/node@7ddbf94

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • dgram.js
  • test/parallel
    • test-dgram-createSocket-type.js
Expand file treeCollapse file tree
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)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.