Establish that the default value of an out-arg for alerts is SSL_AD_DECODE_ERROR.
We already have some cases where the default is DECODE_ERROR and, rather
than have two defaults, just harmonise on that. (INTERNAL_ERROR might
make more sense in some cases, but we don't want to have to remember
what the default is in each case and nobody really cares what the actual
value is anyway.)
Change-Id: I28007898e8d6e7415219145eb9f43ea875028ab2
Reviewed-on: https://boringssl-review.googlesource.com/13720
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/ssl/handshake_client.c b/ssl/handshake_client.c
index 23a4cff..ad0f06a 100644
--- a/ssl/handshake_client.c
+++ b/ssl/handshake_client.c
@@ -1068,7 +1068,7 @@
CBS cbs;
CBS_init(&cbs, ssl->init_msg, ssl->init_num);
- uint8_t alert;
+ uint8_t alert = SSL_AD_DECODE_ERROR;
sk_CRYPTO_BUFFER_pop_free(ssl->s3->new_session->certs, CRYPTO_BUFFER_free);
EVP_PKEY_free(hs->peer_pubkey);
hs->peer_pubkey = NULL;
@@ -1439,7 +1439,7 @@
}
}
- uint8_t alert;
+ uint8_t alert = SSL_AD_DECODE_ERROR;
STACK_OF(X509_NAME) *ca_sk = ssl_parse_client_CA_list(ssl, &alert, &cbs);
if (ca_sk == NULL) {
ssl3_send_alert(ssl, SSL3_AL_FATAL, alert);
@@ -1619,7 +1619,7 @@
}
/* Compute the premaster. */
- uint8_t alert;
+ uint8_t alert = SSL_AD_DECODE_ERROR;
if (!SSL_ECDH_CTX_accept(&hs->ecdh_ctx, &child, &pms, &pms_len, &alert,
hs->peer_key, hs->peer_key_len)) {
ssl3_send_alert(ssl, SSL3_AL_FATAL, alert);
diff --git a/ssl/handshake_server.c b/ssl/handshake_server.c
index eb6745d..05d960e 100644
--- a/ssl/handshake_server.c
+++ b/ssl/handshake_server.c
@@ -1467,7 +1467,7 @@
sk_CRYPTO_BUFFER_pop_free(ssl->s3->new_session->certs, CRYPTO_BUFFER_free);
EVP_PKEY_free(hs->peer_pubkey);
hs->peer_pubkey = NULL;
- uint8_t alert;
+ uint8_t alert = SSL_AD_DECODE_ERROR;
ssl->s3->new_session->certs =
ssl_parse_cert_chain(&alert, &hs->peer_pubkey,
ssl->retain_only_sha256_of_client_certs
@@ -1719,7 +1719,7 @@
}
/* Compute the premaster. */
- uint8_t alert;
+ uint8_t alert = SSL_AD_DECODE_ERROR;
if (!SSL_ECDH_CTX_finish(&hs->ecdh_ctx, &premaster_secret,
&premaster_secret_len, &alert, CBS_data(&peer_key),
CBS_len(&peer_key))) {
diff --git a/ssl/s3_pkt.c b/ssl/s3_pkt.c
index 5d5b7e8..2f919ca 100644
--- a/ssl/s3_pkt.c
+++ b/ssl/s3_pkt.c
@@ -140,7 +140,7 @@
}
CBS body;
- uint8_t type, alert;
+ uint8_t type, alert = SSL_AD_DECODE_ERROR;
size_t consumed;
enum ssl_open_record_t open_ret =
tls_open_record(ssl, &type, &body, &consumed, &alert,
diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c
index d66a2e6..cf46742 100644
--- a/ssl/t1_lib.c
+++ b/ssl/t1_lib.c
@@ -2962,7 +2962,7 @@
int ssl_parse_clienthello_tlsext(SSL_HANDSHAKE *hs,
const SSL_CLIENT_HELLO *client_hello) {
SSL *const ssl = hs->ssl;
- int alert = -1;
+ int alert = SSL_AD_DECODE_ERROR;
if (ssl_scan_clienthello_tlsext(hs, client_hello, &alert) <= 0) {
ssl3_send_alert(ssl, SSL3_AL_FATAL, alert);
return 0;
@@ -3085,7 +3085,7 @@
int ssl_parse_serverhello_tlsext(SSL_HANDSHAKE *hs, CBS *cbs) {
SSL *const ssl = hs->ssl;
- int alert = -1;
+ int alert = SSL_AD_DECODE_ERROR;
if (ssl_scan_serverhello_tlsext(hs, cbs, &alert) <= 0) {
ssl3_send_alert(ssl, SSL3_AL_FATAL, alert);
return 0;
diff --git a/ssl/tls13_both.c b/ssl/tls13_both.c
index 1c4168c..9e9da44 100644
--- a/ssl/tls13_both.c
+++ b/ssl/tls13_both.c
@@ -232,7 +232,7 @@
{TLSEXT_TYPE_certificate_timestamp, &have_sct, &sct},
};
- uint8_t alert;
+ uint8_t alert = SSL_AD_DECODE_ERROR;
if (!ssl_parse_extensions(&extensions, &alert, ext_types,
OPENSSL_ARRAY_SIZE(ext_types),
0 /* reject unknown */)) {
diff --git a/ssl/tls13_client.c b/ssl/tls13_client.c
index 85f4792..fc94d2f 100644
--- a/ssl/tls13_client.c
+++ b/ssl/tls13_client.c
@@ -74,7 +74,7 @@
{TLSEXT_TYPE_cookie, &have_cookie, &cookie},
};
- uint8_t alert;
+ uint8_t alert = SSL_AD_DECODE_ERROR;
if (!ssl_parse_extensions(&extensions, &alert, ext_types,
OPENSSL_ARRAY_SIZE(ext_types),
0 /* reject unknown */)) {
@@ -207,7 +207,7 @@
{TLSEXT_TYPE_short_header, &have_short_header, &short_header},
};
- uint8_t alert;
+ uint8_t alert = SSL_AD_DECODE_ERROR;
if (!ssl_parse_extensions(&extensions, &alert, ext_types,
OPENSSL_ARRAY_SIZE(ext_types),
0 /* reject unknown */)) {
@@ -297,6 +297,7 @@
/* Resolve ECDHE and incorporate it into the secret. */
uint8_t *dhe_secret;
size_t dhe_secret_len;
+ alert = SSL_AD_DECODE_ERROR;
if (!ssl_ext_key_share_parse_serverhello(hs, &dhe_secret, &dhe_secret_len,
&alert, &key_share)) {
ssl3_send_alert(ssl, SSL3_AL_FATAL, alert);
@@ -392,7 +393,7 @@
return ssl_hs_error;
}
- uint8_t alert;
+ uint8_t alert = SSL_AD_DECODE_ERROR;
STACK_OF(X509_NAME) *ca_sk = ssl_parse_client_CA_list(ssl, &alert, &cbs);
if (ca_sk == NULL) {
ssl3_send_alert(ssl, SSL3_AL_FATAL, alert);
@@ -662,7 +663,7 @@
&early_data_info},
};
- uint8_t alert;
+ uint8_t alert = SSL_AD_DECODE_ERROR;
if (!ssl_parse_extensions(&extensions, &alert, ext_types,
OPENSSL_ARRAY_SIZE(ext_types),
1 /* ignore unknown */)) {
diff --git a/ssl/tls13_server.c b/ssl/tls13_server.c
index ed9191a..e9ba86f 100644
--- a/ssl/tls13_server.c
+++ b/ssl/tls13_server.c
@@ -237,6 +237,7 @@
/* HTTP/2 negotiation depends on the cipher suite, so ALPN negotiation was
* deferred. Complete it now. */
+ alert = SSL_AD_DECODE_ERROR;
if (!ssl_negotiate_alpn(hs, &alert, &client_hello)) {
ssl3_send_alert(ssl, SSL3_AL_FATAL, alert);
return ssl_hs_error;