We have defines for alert levels - use them instead of magic numbers.
authorjsing <jsing@openbsd.org>
Sat, 31 Jul 2021 09:31:04 +0000 (09:31 +0000)
committerjsing <jsing@openbsd.org>
Sat, 31 Jul 2021 09:31:04 +0000 (09:31 +0000)
lib/libssl/d1_pkt.c
lib/libssl/ssl_pkt.c

index acd66e6..6963e58 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: d1_pkt.c,v 1.104 2021/07/26 03:17:38 jsing Exp $ */
+/* $OpenBSD: d1_pkt.c,v 1.105 2021/07/31 09:31:04 jsing Exp $ */
 /*
  * DTLS implementation written by Nagendra Modadugu
  * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
@@ -786,15 +786,13 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
                        cb(s, SSL_CB_READ_ALERT, j);
                }
 
-               if (alert_level == 1) /* warning */
-               {
+               if (alert_level == SSL3_AL_WARNING) {
                        S3I(s)->warn_alert = alert_descr;
                        if (alert_descr == SSL_AD_CLOSE_NOTIFY) {
                                s->internal->shutdown |= SSL_RECEIVED_SHUTDOWN;
                                return (0);
                        }
-               } else if (alert_level == 2) /* fatal */
-               {
+               } else if (alert_level == SSL3_AL_FATAL) {
                        s->internal->rwstate = SSL_NOTHING;
                        S3I(s)->fatal_alert = alert_descr;
                        SSLerror(s, SSL_AD_REASON_OFFSET + alert_descr);
index c3fd4a7..2b1a6a4 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_pkt.c,v 1.46 2021/07/26 03:17:38 jsing Exp $ */
+/* $OpenBSD: ssl_pkt.c,v 1.47 2021/07/31 09:31:04 jsing Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -1204,7 +1204,7 @@ int
 ssl3_send_alert(SSL *s, int level, int desc)
 {
        /* If a fatal one, remove from cache */
-       if ((level == 2) && (s->session != NULL))
+       if ((level == SSL3_AL_FATAL) && (s->session != NULL))
                SSL_CTX_remove_session(s->ctx, s->session);
 
        S3I(s)->alert_dispatch = 1;