summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2023-04-26 15:56:59 +0100
committerHugo Landau <hlandau@openssl.org>2023-05-12 14:47:14 +0100
commit22b1a96ff798cf73f4b573bff1d9f80236d3f102 (patch)
tree57096e855e78c11b08d4bc04dc5f015975c2142c
parent496b8162b6b7048a05809f5e85825ed02dff8a7c (diff)
downloadopenssl-new-22b1a96ff798cf73f4b573bff1d9f80236d3f102.tar.gz
QUIC MSST: Minor fixes and cleanups
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20765)
-rw-r--r--include/internal/quic_stream_map.h2
-rw-r--r--include/openssl/ssl.h.in4
-rw-r--r--ssl/quic/quic_channel.c6
-rw-r--r--ssl/quic/quic_impl.c8
-rw-r--r--ssl/ssl_lib.c11
5 files changed, 13 insertions, 18 deletions
diff --git a/include/internal/quic_stream_map.h b/include/internal/quic_stream_map.h
index 5d21c60185..920f3144b4 100644
--- a/include/internal/quic_stream_map.h
+++ b/include/internal/quic_stream_map.h
@@ -129,7 +129,7 @@ struct quic_stream_st {
* queue nor has an associated XSO. This condition occurs when and only
* when deleted is true.
*
- * - Once there is the case (i.e., no user-facing API object exposing the
+ * - Once this is the case (i.e., no user-facing API object exposing the
* stream), we can delete the stream once we determine that all of our
* protocol obligations requiring us to keep the QUIC_STREAM around have
* been met.
diff --git a/include/openssl/ssl.h.in b/include/openssl/ssl.h.in
index 81d49e6299..fc326a573f 100644
--- a/include/openssl/ssl.h.in
+++ b/include/openssl/ssl.h.in
@@ -2270,8 +2270,8 @@ __owur SSL *SSL_get0_connection(SSL *s);
__owur int SSL_is_connection(SSL *s);
#define SSL_STREAM_TYPE_NONE 0
-#define SSL_STREAM_TYPE_READ 1
-#define SSL_STREAM_TYPE_WRITE 2
+#define SSL_STREAM_TYPE_READ (1U << 0)
+#define SSL_STREAM_TYPE_WRITE (1U << 1)
#define SSL_STREAM_TYPE_BIDI (SSL_STREAM_TYPE_READ | SSL_STREAM_TYPE_WRITE)
__owur int SSL_get_stream_type(SSL *s);
diff --git a/ssl/quic/quic_channel.c b/ssl/quic/quic_channel.c
index 7e55b7b5c6..cb1c99bfcf 100644
--- a/ssl/quic/quic_channel.c
+++ b/ssl/quic/quic_channel.c
@@ -2301,11 +2301,11 @@ err:
QUIC_STREAM *ossl_quic_channel_new_stream_local(QUIC_CHANNEL *ch, int is_uni)
{
QUIC_STREAM *qs;
- int type = 0;
+ int type;
uint64_t stream_id, *p_next_ordinal;
- type |= ch->is_server ? QUIC_STREAM_INITIATOR_SERVER
- : QUIC_STREAM_INITIATOR_CLIENT;
+ type = ch->is_server ? QUIC_STREAM_INITIATOR_SERVER
+ : QUIC_STREAM_INITIATOR_CLIENT;
if (is_uni) {
p_next_ordinal = &ch->next_local_stream_ordinal_uni;
diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c
index cce1bde5c4..581117d537 100644
--- a/ssl/quic/quic_impl.c
+++ b/ssl/quic/quic_impl.c
@@ -341,6 +341,8 @@ void ossl_quic_free(SSL *s)
if (!expect_quic(s, &ctx))
return;
+ quic_lock(ctx.qc);
+
if (ctx.is_stream) {
/*
* When a QSSO is freed, the XSO is freed immediately, because the XSO
@@ -349,8 +351,6 @@ void ossl_quic_free(SSL *s)
* as deleted for later collection.
*/
- quic_lock(ctx.qc);
-
assert(ctx.qc->num_xso > 0);
--ctx.qc->num_xso;
@@ -376,8 +376,6 @@ void ossl_quic_free(SSL *s)
return;
}
- quic_lock(ctx.qc);
-
/*
* Free the default XSO, if any. The QUIC_STREAM is not deleted at this
* stage, but is freed during the channel free when the whole QSM is freed.
@@ -1902,7 +1900,7 @@ QUIC_TAKES_LOCK
static size_t ossl_quic_pending_int(const SSL *s)
{
QCTX ctx;
- size_t avail = 0;
+ size_t avail;
int fin = 0;
if (!expect_quic_with_stream_lock(s, /*remote_init=*/-1, &ctx))
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index ad3b1ed15d..f7e3f497b8 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -1874,14 +1874,12 @@ int SSL_has_pending(const SSL *s)
* the records for some reason.
*/
const SSL_CONNECTION *sc;
-#ifndef OPENSSL_NO_QUIC
- const QUIC_CONNECTION *qc = QUIC_CONNECTION_FROM_CONST_SSL(s);
- if (qc != NULL)
+#ifndef OPENSSL_NO_QUIC
+ if (IS_QUIC(s))
return ossl_quic_has_pending(s);
#endif
-
sc = SSL_CONNECTION_FROM_CONST_SSL(s);
/* Check buffered app data if any first */
@@ -2692,10 +2690,9 @@ int SSL_shutdown(SSL *s)
* (see ssl3_shutdown).
*/
SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL(s);
-#ifndef OPENSSL_NO_QUIC
- QUIC_CONNECTION *qc = QUIC_CONNECTION_FROM_SSL(s);
- if (qc != NULL)
+#ifndef OPENSSL_NO_QUIC
+ if (IS_QUIC(s))
return ossl_quic_conn_shutdown(s, 0, NULL, 0);
#endif