From e662060166f881e94d14702c1fda2b4fbdeeb041 Mon Sep 17 00:00:00 2001
From: Todd Short <tshort@akamai.com>
Date: Wed, 3 Mar 2021 17:43:46 -0500
Subject: [PATCH 29/43] QUIC: SSLerr() -> ERR_raise(ERR_LIB_SSL)

---
 ssl/s3_msg.c            |  2 +-
 ssl/ssl_lib.c           |  6 +++---
 ssl/ssl_quic.c          | 17 ++++++++---------
 ssl/statem/statem.c     |  2 +-
 ssl/statem/statem_lib.c |  4 ++--
 5 files changed, 15 insertions(+), 16 deletions(-)

--- a/ssl/s3_msg.c
+++ b/ssl/s3_msg.c
@@ -85,7 +85,7 @@ int ssl3_dispatch_alert(SSL *s)
     if (SSL_IS_QUIC(s)) {
         if (!s->quic_method->send_alert(s, s->quic_write_level,
                                         s->s3.send_alert[1])) {
-            SSLerr(SSL_F_SSL3_DISPATCH_ALERT, ERR_R_INTERNAL_ERROR);
+            ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
             return 0;
         }
         i = 1;
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -1872,7 +1872,7 @@ int ssl_read_internal(SSL *s, void *buf,
 {
 #ifndef OPENSSL_NO_QUIC
     if (SSL_IS_QUIC(s)) {
-        SSLerr(SSL_F_SSL_READ_INTERNAL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
+        ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
         return -1;
     }
 #endif
@@ -2009,7 +2009,7 @@ static int ssl_peek_internal(SSL *s, voi
 {
 #ifndef OPENSSL_NO_QUIC
     if (SSL_IS_QUIC(s)) {
-        SSLerr(SSL_F_SSL_PEEK_INTERNAL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
+        ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
         return -1;
     }
 #endif
@@ -2075,7 +2075,7 @@ int ssl_write_internal(SSL *s, const voi
 {
 #ifndef OPENSSL_NO_QUIC
     if (SSL_IS_QUIC(s)) {
-        SSLerr(SSL_F_SSL_WRITE_INTERNAL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
+        ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
         return -1;
     }
 #endif
--- a/ssl/ssl_quic.c
+++ b/ssl/ssl_quic.c
@@ -131,7 +131,7 @@ int SSL_provide_quic_data(SSL *ssl, OSSL
     size_t l, offset;
 
     if (!SSL_IS_QUIC(ssl)) {
-        SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
+        ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
         return 0;
     }
 
@@ -139,18 +139,18 @@ int SSL_provide_quic_data(SSL *ssl, OSSL
     if (level < ssl->quic_read_level
             || (ssl->quic_input_data_tail != NULL && level < ssl->quic_input_data_tail->level)
             || level < ssl->quic_latest_level_received) {
-        SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA, SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED);
+        ERR_raise(ERR_LIB_SSL, SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED);
         return 0;
     }
 
     if (ssl->quic_buf == NULL) {
         BUF_MEM *buf;
         if ((buf = BUF_MEM_new()) == NULL) {
-            SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA, ERR_R_INTERNAL_ERROR);
+            ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
             return 0;
         }
         if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) {
-            SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA, ERR_R_INTERNAL_ERROR);
+            ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
             BUF_MEM_free(buf);
             return 0;
         }
@@ -163,15 +163,14 @@ int SSL_provide_quic_data(SSL *ssl, OSSL
     /* A TLS message must not cross an encryption level boundary */
     if (ssl->quic_buf->length != ssl->quic_next_record_start
             && level != ssl->quic_latest_level_received) {
-        SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA,
-               SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED);
+        ERR_raise(ERR_LIB_SSL, SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED);
         return 0;
     }
     ssl->quic_latest_level_received = level;
 
     offset = ssl->quic_buf->length;
     if (!BUF_MEM_grow(ssl->quic_buf, offset + len)) {
-        SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA, ERR_R_INTERNAL_ERROR);
+        ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
         return 0;
     }
     memcpy(ssl->quic_buf->data + offset, data, len);
@@ -193,7 +192,7 @@ int SSL_provide_quic_data(SSL *ssl, OSSL
 
         qd = OPENSSL_zalloc(sizeof(*qd));
         if (qd == NULL) {
-            SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA, ERR_R_INTERNAL_ERROR);
+            ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
             return 0;
         }
 
@@ -305,7 +304,7 @@ int SSL_process_quic_post_handshake(SSL
     int ret;
 
     if (SSL_in_init(ssl) || !SSL_IS_QUIC(ssl)) {
-        SSLerr(SSL_F_SSL_PROCESS_QUIC_POST_HANDSHAKE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
+        ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
         return 0;
     }
 
--- a/ssl/statem/statem.c
+++ b/ssl/statem/statem.c
@@ -930,7 +930,7 @@ int statem_flush(SSL *s)
 #ifndef OPENSSL_NO_QUIC
     if (SSL_IS_QUIC(s)) {
         if (!s->quic_method->flush_flight(s)) {
-            SSLerr(SSL_F_STATEM_FLUSH, ERR_R_INTERNAL_ERROR);
+            ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
             return 0;
         }
     } else
--- a/ssl/statem/statem_lib.c
+++ b/ssl/statem/statem_lib.c
@@ -54,14 +54,14 @@ int ssl3_do_write(SSL *s, int type)
             if (!ret) {
                 ret = -1;
                 /* QUIC can't sent anything out sice the above failed */
-                SSLerr(SSL_F_SSL3_DO_WRITE, ERR_R_INTERNAL_ERROR);
+                ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
             } else {
                 written = s->init_num;
             }
         } else {
             /* QUIC doesn't use ChangeCipherSpec */
             ret = -1;
-            SSLerr(SSL_F_SSL3_DO_WRITE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
+            ERR_raise(ERR_LIB_SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
         }
     } else
 #endif
