Change QuicCryptoServerConfig::ParseSourceAddressToken from taking a 'SourceAddressTokens*' to a 'SourceAddressTokens&'. The function dereferences this pointer without checking for nullptr, changing it to reference prevents caller from passing in a nullptr.
IIRC, the old style guide requires output parameters to be pointers, but it has been changed to be non-const references: go/cstyle#Inputs_and_Outputs
PiperOrigin-RevId: 409498556
diff --git a/quic/core/crypto/quic_crypto_server_config.cc b/quic/core/crypto/quic_crypto_server_config.cc
index fd8041b..16a53fa 100644
--- a/quic/core/crypto/quic_crypto_server_config.cc
+++ b/quic/core/crypto/quic_crypto_server_config.cc
@@ -1247,7 +1247,7 @@
configs.requested != nullptr ? *configs.requested : *configs.primary;
source_address_token_error =
ParseSourceAddressToken(*config.source_address_token_boxer, srct,
- &info->source_address_tokens);
+ info->source_address_tokens);
if (source_address_token_error == HANDSHAKE_OK) {
source_address_token_error = ValidateSourceAddressTokens(
@@ -1754,16 +1754,15 @@
}
HandshakeFailureReason QuicCryptoServerConfig::ParseSourceAddressToken(
- const CryptoSecretBoxer& crypto_secret_boxer,
- absl::string_view token,
- SourceAddressTokens* tokens) const {
+ const CryptoSecretBoxer& crypto_secret_boxer, absl::string_view token,
+ SourceAddressTokens& tokens) const {
std::string storage;
absl::string_view plaintext;
if (!crypto_secret_boxer.Unbox(token, &storage, &plaintext)) {
return SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE;
}
- if (!tokens->ParseFromArray(plaintext.data(), plaintext.size())) {
+ if (!tokens.ParseFromArray(plaintext.data(), plaintext.size())) {
// Some clients might still be using the old source token format so
// attempt to parse that format.
// TODO(rch): remove this code once the new format is ubiquitous.
@@ -1771,7 +1770,7 @@
if (!token.ParseFromArray(plaintext.data(), plaintext.size())) {
return SOURCE_ADDRESS_TOKEN_PARSE_FAILURE;
}
- *tokens->add_tokens() = token;
+ *tokens.add_tokens() = token;
}
return HANDSHAKE_OK;
diff --git a/quic/core/crypto/quic_crypto_server_config.h b/quic/core/crypto/quic_crypto_server_config.h
index d8e77e6..ca6dbe5 100644
--- a/quic/core/crypto/quic_crypto_server_config.h
+++ b/quic/core/crypto/quic_crypto_server_config.h
@@ -431,9 +431,8 @@
// Returns HANDSHAKE_OK if |token| could be parsed, or the reason for the
// failure.
HandshakeFailureReason ParseSourceAddressToken(
- const CryptoSecretBoxer& crypto_secret_boxer,
- absl::string_view token,
- SourceAddressTokens* tokens) const;
+ const CryptoSecretBoxer& crypto_secret_boxer, absl::string_view token,
+ SourceAddressTokens& tokens) const;
// ValidateSourceAddressTokens returns HANDSHAKE_OK if the source address
// tokens in |tokens| contain a valid and timely token for the IP address
diff --git a/quic/core/tls_server_handshaker.cc b/quic/core/tls_server_handshaker.cc
index 9d66887..bc0d361 100644
--- a/quic/core/tls_server_handshaker.cc
+++ b/quic/core/tls_server_handshaker.cc
@@ -337,7 +337,7 @@
bool TlsServerHandshaker::ValidateAddressToken(absl::string_view token) const {
SourceAddressTokens tokens;
HandshakeFailureReason reason = crypto_config_->ParseSourceAddressToken(
- crypto_config_->source_address_token_boxer(), token, &tokens);
+ crypto_config_->source_address_token_boxer(), token, tokens);
if (reason != HANDSHAKE_OK) {
QUIC_DLOG(WARNING) << "Failed to parse source address token: "
<< CryptoUtils::HandshakeFailureReasonToString(reason);
diff --git a/quic/test_tools/quic_crypto_server_config_peer.cc b/quic/test_tools/quic_crypto_server_config_peer.cc
index f2fff70..edf473c 100644
--- a/quic/test_tools/quic_crypto_server_config_peer.cc
+++ b/quic/test_tools/quic_crypto_server_config_peer.cc
@@ -59,7 +59,7 @@
CachedNetworkParameters* cached_network_params) {
SourceAddressTokens tokens;
HandshakeFailureReason reason = server_config_->ParseSourceAddressToken(
- *GetConfig(config_id)->source_address_token_boxer, srct, &tokens);
+ *GetConfig(config_id)->source_address_token_boxer, srct, tokens);
if (reason != HANDSHAKE_OK) {
return reason;
}
@@ -75,7 +75,7 @@
QuicWallTime now) {
SourceAddressTokens tokens;
HandshakeFailureReason parse_status = server_config_->ParseSourceAddressToken(
- *GetPrimaryConfig()->source_address_token_boxer, token, &tokens);
+ *GetPrimaryConfig()->source_address_token_boxer, token, tokens);
if (HANDSHAKE_OK != parse_status) {
return parse_status;
}
diff --git a/quic/test_tools/quic_crypto_server_config_peer.h b/quic/test_tools/quic_crypto_server_config_peer.h
index a76a586..8e0e5e7 100644
--- a/quic/test_tools/quic_crypto_server_config_peer.h
+++ b/quic/test_tools/quic_crypto_server_config_peer.h
@@ -40,13 +40,10 @@
QuicWallTime now,
CachedNetworkParameters* cached_network_params);
- // Attempts to validate the tokens in |tokens|.
+ // Attempts to validate the tokens in |srct|.
HandshakeFailureReason ValidateSourceAddressTokens(
- std::string config_id,
- absl::string_view tokens,
- const QuicIpAddress& ip,
- QuicWallTime now,
- CachedNetworkParameters* cached_network_params);
+ std::string config_id, absl::string_view srct, const QuicIpAddress& ip,
+ QuicWallTime now, CachedNetworkParameters* cached_network_params);
// Attempts to validate the single source address token in |token|.
HandshakeFailureReason ValidateSingleSourceAddressToken(