Skip to content

Commit 3c4a452

Browse files
committed
quic: don't allow combining appTicketData with Http3Session
1 parent f4b3a00 commit 3c4a452

4 files changed

Lines changed: 26 additions & 5 deletions

File tree

lib/internal/quic/quic.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4574,6 +4574,11 @@ function processSessionOptions(options, config = kEmptyObject) {
45744574
throw new ERR_INVALID_ARG_TYPE('options.appTicketData',
45754575
['ArrayBufferView'], appTicketData);
45764576
}
4577+
if (application !== undefined) {
4578+
throw new ERR_INVALID_ARG_VALUE(
4579+
'options.appTicketData', appTicketData,
4580+
'cannot be combined with a session application');
4581+
}
45774582
}
45784583

45794584
if (cc !== undefined) {

src/quic/http3.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1829,7 +1829,9 @@ void CreateHttp3Handle(const FunctionCallbackInfo<Value>& args) {
18291829
"becomes active (begins emitting events)");
18301830
return;
18311831
}
1832-
session->SetApplication(CreateHttp3Application(session));
1832+
if (!session->AttachApplication(CreateHttp3Application(session))) {
1833+
return;
1834+
}
18331835

18341836
if (session->is_server() && !session->application().Start()) {
18351837
// Start() failed (e.g. the peer's initial_max_streams_uni is < 3), so

src/quic/session.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,6 +2864,17 @@ std::unique_ptr<Session::Application> Session::SelectApplication() {
28642864
return factory->create(this);
28652865
}
28662866

2867+
bool Session::AttachApplication(std::unique_ptr<Application> app) {
2868+
if (config().options.app_ticket_data.has_value()) {
2869+
THROW_ERR_INVALID_STATE(
2870+
env(),
2871+
"A QUIC application cannot be combined with appTicketData");
2872+
return false;
2873+
}
2874+
SetApplication(std::move(app));
2875+
return true;
2876+
}
2877+
28672878
void Session::SetApplication(std::unique_ptr<Application> app) {
28682879
DCHECK(!impl_->application_);
28692880
DCHECK(app);

src/quic/session.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,14 @@ class Session final : public AsyncWrap, private SessionTicket::AppData::Source {
9090
// path and no Application is ever installed.
9191
std::unique_ptr<Application> SelectApplication();
9292

93-
// Install the Application on the session. Called at construction for
94-
// clients or from OnSelectAlpn for servers (later in the handshake,
95-
// after session-ticket decryption). Must be called before any
96-
// application data is received.
93+
// Installs the Application on the session WITHOUT validation. Called at
94+
// construction for clients or from OnSelectAlpn for servers (later in the
95+
// handshake, after session-ticket decryption).
9796
void SetApplication(std::unique_ptr<Application> app);
97+
98+
// Validating wrapper around SetApplication() for dynamic attachment of an
99+
// application to a live session.
100+
bool AttachApplication(std::unique_ptr<Application> app);
98101
// Controls which datagram to drop when the pending datagram queue is full.
99102
enum class DatagramDropPolicy : uint8_t {
100103
DROP_OLDEST = 0, // Drop the oldest queued datagram (default).

0 commit comments

Comments
 (0)