Introduce IsConnectionIdLengthValidForVersion
This CL is part of a larger change to allow the new connection ID invariants. It adds a new method QuicUtils::IsConnectionIdLengthValidForVersion() whose goal will be to replace uses of kQuicMaxConnectionIdLength in the codebase. This CL also plumbs the QUIC version to the TLS transport parameter parse/serialize code so it can call IsConnectionIdLengthValidForVersion. I suspect the transport parameter code will eventually need the version anyway as we create more QUIC versions that support TLS.
gfe-relnote: refactor, protected by disabled quic_enable_v47 flag.
PiperOrigin-RevId: 260938227
Change-Id: I590f7117de2b245044469e6dcdcca6f503c7a625
diff --git a/quic/core/quic_connection_id.cc b/quic/core/quic_connection_id.cc
index c560bcc..3ad13a3 100644
--- a/quic/core/quic_connection_id.cc
+++ b/quic/core/quic_connection_id.cc
@@ -125,6 +125,10 @@
}
void QuicConnectionId::set_length(uint8_t length) {
+ if (length > kQuicMaxConnectionIdLength) {
+ QUIC_BUG << "Attempted to set connection ID length to " << length;
+ length = kQuicMaxConnectionIdLength;
+ }
if (GetQuicRestartFlag(quic_use_allocated_connection_ids)) {
QUIC_RESTART_FLAG_COUNT_N(quic_use_allocated_connection_ids, 5, 6);
char temporary_data[sizeof(data_short_)];