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 — quic: validate maxPayloadSize range · nodejs/node@3812387

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • quic.md
  • src/quic
    • session.cc
  • test/parallel
    • test-quic-max-payload-size.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/quic.md‎

Copy file name to clipboardExpand all lines: doc/api/quic.md
+3-1Lines changed: 3 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -3294,8 +3294,10 @@ added: v23.8.0
32943294
-->
32953295

32963296
* Type: {bigint|number}
3297+
* **Default:** `1200`
32973298

3298-
Specifies the maximum UDP packet payload size.
3299+
Specifies the maximum UDP packet payload size. The valid range is `1200` to
3300+
`65527`.
32993301

33003302
#### `sessionOptions.maxStreamWindow`
33013303

Collapse file

‎src/quic/session.cc‎

Copy file name to clipboardExpand all lines: src/quic/session.cc
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,20 @@ Maybe<Session::Options> Session::Options::From(Environment* env,
629629

630630
#undef SET
631631

632+
// ngtcp2 only asserts this range. With assertions compiled out, a value
633+
// below the minimum gives the congestion controller an initial window it
634+
// cannot work with: zero makes it divide by zero as soon as the connection
635+
// is created.
636+
if (options.max_payload_size < NGTCP2_MAX_UDP_PAYLOAD_SIZE ||
637+
options.max_payload_size > NGTCP2_MAX_TX_UDP_PAYLOAD_SIZE) {
638+
THROW_ERR_INVALID_ARG_VALUE(env,
639+
"The maxPayloadSize option must be between "
640+
"%d and %d",
641+
NGTCP2_MAX_UDP_PAYLOAD_SIZE,
642+
NGTCP2_MAX_TX_UDP_PAYLOAD_SIZE);
643+
return Nothing<Options>();
644+
}
645+
632646
// RFC 9000 Section 10.2 requires the draining period to be at least 3x PTO.
633647
static const uint8_t kMinDrainingPeriodMultiplier = 3;
634648
options.draining_period_multiplier = std::max(
Collapse file

‎test/parallel/test-quic-max-payload-size.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-quic-max-payload-size.mjs
+16-1Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// We verify by checking that more packets are needed to transfer
66
// the same amount of data compared to the default.
77

8-
import { hasQuic, skip, mustCall } from '../common/index.mjs';
8+
import { hasQuic, skip, mustCall, mustNotCall } from '../common/index.mjs';
99
import assert from 'node:assert';
1010
import { dump } from 'node:stream/iter';
1111

@@ -55,3 +55,18 @@ const smallPkts = await transferAndGetPacketCount(1200);
5555
// The key assertion: the option is accepted and data transfers correctly.
5656
assert.ok(defaultPkts > 0n);
5757
assert.ok(smallPkts > 0n);
58+
59+
// Both ends of the supported range work, as a number and as a bigint.
60+
for (const maxPayloadSize of [1200n, 65527, 65527n]) {
61+
assert.ok(await transferAndGetPacketCount(maxPayloadSize) > 0n);
62+
}
63+
64+
// Anything outside of the range is rejected before a session is created.
65+
for (const maxPayloadSize of [0, 0n, 1199, 1199n, 65528, 65528n]) {
66+
const expected = {
67+
code: 'ERR_INVALID_ARG_VALUE',
68+
message: 'The maxPayloadSize option must be between 1200 and 65527',
69+
};
70+
await assert.rejects(listen(mustNotCall(), { maxPayloadSize }), expected);
71+
await assert.rejects(connect('127.0.0.1:1', { maxPayloadSize }), expected);
72+
}

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.