]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix SSL_has_pending() for QUIC connections
authorMatt Caswell <matt@openssl.org>
Mon, 13 Mar 2023 14:42:50 +0000 (14:42 +0000)
committerPauli <pauli@openssl.org>
Sun, 19 Mar 2023 22:35:38 +0000 (09:35 +1100)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20514)

include/internal/quic_ssl.h
ssl/quic/quic_impl.c
ssl/ssl_lib.c

index 8846877a4a2ff407bd78a58add68519e9e5360e4..7b89534c22ec1cfb3d2331e79aa55009b1e89b37 100644 (file)
@@ -43,6 +43,7 @@ int ossl_quic_do_handshake(QUIC_CONNECTION *qc);
 void ossl_quic_set_connect_state(QUIC_CONNECTION *qc);
 void ossl_quic_set_accept_state(QUIC_CONNECTION *qc);
 
+__owur int ossl_quic_has_pending(const QUIC_CONNECTION *qc);
 __owur int ossl_quic_tick(QUIC_CONNECTION *qc);
 __owur int ossl_quic_get_tick_timeout(QUIC_CONNECTION *qc, struct timeval *tv);
 __owur int ossl_quic_get_rpoll_descriptor(QUIC_CONNECTION *qc, BIO_POLL_DESCRIPTOR *d);
index 48e1cf7c0ef8116fceb12a4565865290953ca3ab..ba6a863e38fe1d9dd0f322ae8c8602ef5b1bd6d5 100644 (file)
@@ -1194,9 +1194,8 @@ int ossl_quic_peek(SSL *s, void *buf, size_t len, size_t *bytes_read)
  * SSL_pending
  * -----------
  */
-size_t ossl_quic_pending(const SSL *s)
+static size_t ossl_quic_pending_int(const QUIC_CONNECTION *qc)
 {
-    const QUIC_CONNECTION *qc = QUIC_CONNECTION_FROM_CONST_SSL(s);
     size_t avail = 0;
     int fin = 0;
 
@@ -1213,6 +1212,18 @@ size_t ossl_quic_pending(const SSL *s)
     return avail;
 }
 
+size_t ossl_quic_pending(const SSL *s)
+{
+    const QUIC_CONNECTION *qc = QUIC_CONNECTION_FROM_CONST_SSL(s);
+
+    return ossl_quic_pending_int(qc);
+}
+
+int ossl_quic_has_pending(const QUIC_CONNECTION *qc)
+{
+    return ossl_quic_pending_int(qc) > 0;
+}
+
 /*
  * SSL_stream_conclude
  * -------------------
index 1b2c527eb0ae6173ec95e916b292b8899aa7eec8..83510b367a7c9cdb1b1acb238923b8223c215628 100644 (file)
@@ -1829,7 +1829,16 @@ int SSL_has_pending(const SSL *s)
      * That data may not result in any application data, or we may fail to parse
      * the records for some reason.
      */
-    const SSL_CONNECTION *sc = SSL_CONNECTION_FROM_CONST_SSL(s);
+    const SSL_CONNECTION *sc;
+#ifndef OPENSSL_NO_QUIC
+    const QUIC_CONNECTION *qc = QUIC_CONNECTION_FROM_CONST_SSL(s);
+
+    if (qc != NULL)
+        return ossl_quic_has_pending(qc);
+#endif
+
+
+    sc = SSL_CONNECTION_FROM_CONST_SSL(s);
 
     /* Check buffered app data if any first */
     if (SSL_CONNECTION_IS_DTLS(sc)) {