Tidy up the alert-parsing code. Align the DTLS and TLS implementations more. s3_pkt.c's version still has remnants of fragmentable alerts and only one side marks some variables as const. Also use warning/fatal constants rather than the numbers with comments. Change-Id: Ie62d3af1747b6fe4336496c047dfccc9d71fde3f Reviewed-on: https://boringssl-review.googlesource.com/3562 Reviewed-by: Adam Langley <agl@google.com>
diff --git a/ssl/d1_pkt.c b/ssl/d1_pkt.c index aa43445..8cbfe94 100644 --- a/ssl/d1_pkt.c +++ b/ssl/d1_pkt.c
@@ -736,8 +736,8 @@ s->msg_callback(0, s->version, SSL3_RT_ALERT, &rr->data[rr->off], 2, s, s->msg_callback_arg); } - uint8_t alert_level = rr->data[rr->off++]; - uint8_t alert_descr = rr->data[rr->off++]; + const uint8_t alert_level = rr->data[rr->off++]; + const uint8_t alert_descr = rr->data[rr->off++]; rr->length -= 2; if (s->info_callback != NULL) { @@ -751,13 +751,13 @@ cb(s, SSL_CB_READ_ALERT, alert); } - if (alert_level == 1) { /* warning */ + if (alert_level == SSL3_AL_WARNING) { s->s3->warn_alert = alert_descr; if (alert_descr == SSL_AD_CLOSE_NOTIFY) { s->shutdown |= SSL_RECEIVED_SHUTDOWN; return 0; } - } else if (alert_level == 2) { /* fatal */ + } else if (alert_level == SSL3_AL_FATAL) { char tmp[16]; s->rwstate = SSL_NOTHING;