Skip to content
Open
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
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(
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