diff options
author | Matt Caswell <matt@openssl.org> | 2023-03-13 14:42:50 +0000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-03-20 09:35:38 +1100 |
commit | 560470b5d97ea5f122d53d1b85e9f384f8ba9023 (patch) | |
tree | ce252bc9b1ba6234e4d0444b9e518d1ecc81eb2f /ssl | |
parent | 44a1ac5de0cb422bc65089e1e3bf1b46bb8ab141 (diff) |
Fix SSL_has_pending() for QUIC connections
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20514)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/quic/quic_impl.c | 15 | ||||
-rw-r--r-- | ssl/ssl_lib.c | 11 |
2 files changed, 23 insertions, 3 deletions
diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index 48e1cf7c0e..ba6a863e38 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -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 * ------------------- diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 1b2c527eb0..83510b367a 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -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)) { |