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: fix abort on negative zero buffer size · nodejs/node@9445ced

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • dgram.js
  • test/parallel
    • test-dgram-negative-zero.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
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ function bufferSize(self, size, buffer) {
250250
throw new ERR_SOCKET_BAD_BUFFER_SIZE();
251251

252252
const ctx = {};
253-
const ret = self[kStateSymbol].handle.bufferSize(size, buffer, ctx);
253+
// Coerce -0 to +0, which the binding does not treat as a Uint32.
254+
const ret = self[kStateSymbol].handle.bufferSize(size >>> 0, buffer, ctx);
254255
if (ret === undefined) {
255256
throw new ERR_SOCKET_BUFFER_SIZE(ctx);
256257
}
Collapse file

‎test/parallel/test-dgram-negative-zero.js‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const dgram = require('dgram');
5+
6+
const socket = dgram.createSocket('udp4');
7+
8+
socket.bind(0, common.mustCall(() => {
9+
socket.setRecvBufferSize(-0);
10+
socket.setSendBufferSize(-0);
11+
socket.close();
12+
}));

0 commit comments

Comments
0 (0)
You are visitor 01402775 — 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.