Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/api/quic.md
Original file line number Diff line number Diff line change
Expand Up @@ -2779,8 +2779,8 @@ added: v23.8.0

The endpoint maintains an internal cache of validated socket addresses as a
performance optimization. This option sets the maximum number of addresses
that are cached. This is an advanced option that users typically won't have
need to specify.
that are cached. The value must be greater than `0`. This is an advanced option
that users typically won't have need to specify.

#### `endpointOptions.disableStatelessReset`

Expand Down
11 changes: 11 additions & 0 deletions src/quic/endpoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ Maybe<Endpoint::Options> Endpoint::Options::From(Environment* env,
return Nothing<Options>();
}

// SocketAddressLRU::Upsert requires a positive capacity. With max_size_ ==
// 0, the newly inserted entry is immediately evicted, and the final
// map_[address] creates a default list iterator that is then
// dereferenced, causing UB (observed as a SIGSEGV in Endpoint::Receive on
// the first accepted connection).
if (options.address_lru_size == 0) {
THROW_ERR_INVALID_ARG_VALUE(
Comment thread
trivikr marked this conversation as resolved.
env, "The addressLRUSize option must be greater than 0");
return Nothing<Options>();
}

Local<Value> address;
if (!params->Get(env->context(), env->address_string()).ToLocal(&address)) {
return Nothing<Options>();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-quic-internal-endpoint-options.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const cases = [
valid: [
1, 10, 100, 1000, 10000, 10000n,
],
invalid: [-1, -1n, 'a', null, false, true, {}, [], () => {}]
invalid: [-1, -1n, 0, 0n, 'a', null, false, true, {}, [], () => {}]
},
{
key: 'retryRate',
Expand Down
Loading