QUIC SSL: Buffer Management
authorHugo Landau <hlandau@openssl.org>
Mon, 16 Jan 2023 15:27:50 +0000 (15:27 +0000)
committerPauli <pauli@openssl.org>
Tue, 4 Jul 2023 23:02:26 +0000 (09:02 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20061)

doc/man3/SSL_alloc_buffers.pod
ssl/ssl_lib.c
test/quicapitest.c

index 678640a56933b7e4c8a167787620ce897aee13eb..d2d5b1e59b4bff1509b4cad43ed9dfee03608768 100644 (file)
@@ -26,6 +26,9 @@ can be used to make sure the buffers are preallocated. This can be used to
 avoid allocation during data processing or with CRYPTO_set_mem_functions()
 to control where and how buffers are allocated.
 
+These functions are no-ops when used with QUIC SSL objects. For QUIC,
+SSL_free_buffers() always fails, and SSL_alloc_buffers() always succeeds.
+
 =head1 RETURN VALUES
 
 The following return values can occur:
index 11f6cb2be95df20f4e3a70d5cfa0446bc4038f6a..036cc83ca0608509414d34652efe7afe94ebcbdf 100644 (file)
@@ -6583,6 +6583,10 @@ int SSL_free_buffers(SSL *ssl)
     if (sc == NULL)
         return 0;
 
+    /* QUIC buffers are always 'in use'. */
+    if (IS_QUIC_SSL(ssl))
+        return 0;
+
     rl = &sc->rlayer;
 
     return rl->rrlmethod->free_buffers(rl->rrl)
@@ -6597,6 +6601,10 @@ int SSL_alloc_buffers(SSL *ssl)
     if (sc == NULL)
         return 0;
 
+    /* QUIC always has buffers allocated. */
+    if (IS_QUIC_SSL(ssl))
+        return 1;
+
     rl = &sc->rlayer;
 
     return rl->rrlmethod->alloc_buffers(rl->rrl)
index 5255674384639f5ba799365e142caa3d4bbaa27b..d85dbcff6043c019030c926343f2a77b65357525 100644 (file)
@@ -489,6 +489,11 @@ static int test_quic_forbidden_options(void)
         || !TEST_false(SSL_write_early_data(ssl, buf, sizeof(buf), &len)))
         goto err;
 
+    /* Buffer Management */
+    if (!TEST_true(SSL_allocate_buffers(ssl))
+        || !TEST_false(SSL_free_buffers(ssl)))
+        goto err;
+
     testresult = 1;
 err:
     SSL_free(ssl);