Move CBB_init() to a consistent place.
authortb <tb@openbsd.org>
Fri, 5 Aug 2022 17:06:17 +0000 (17:06 +0000)
committertb <tb@openbsd.org>
Fri, 5 Aug 2022 17:06:17 +0000 (17:06 +0000)
regress/lib/libssl/tlsext/tlsexttest.c

index 918d9c5..a224623 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: tlsexttest.c,v 1.70 2022/08/05 17:03:33 tb Exp $ */
+/* $OpenBSD: tlsexttest.c,v 1.71 2022/08/05 17:06:17 tb Exp $ */
 /*
  * Copyright (c) 2017 Joel Sing <jsing@openbsd.org>
  * Copyright (c) 2017 Doug Hogan <doug@openbsd.org>
@@ -1791,6 +1791,9 @@ test_tlsext_sni_client(void)
 
        failure = 1;
 
+       if (!CBB_init(&cbb, 0))
+               errx(1, "Failed to create CBB");
+
        if ((ssl_ctx = SSL_CTX_new(TLS_client_method())) == NULL)
                errx(1, "failed to create SSL_CTX");
        if ((ssl = SSL_new(ssl_ctx)) == NULL)
@@ -1800,9 +1803,6 @@ test_tlsext_sni_client(void)
            &server_funcs))
                errx(1, "failed to fetch sni funcs");
 
-       if (!CBB_init(&cbb, 0))
-               errx(1, "Failed to create CBB");
-
        if (client_funcs->needs(ssl, SSL_TLSEXT_MSG_CH)) {
                FAIL("client should not need SNI\n");
                goto err;
@@ -2053,6 +2053,9 @@ test_tlsext_quic_transport_parameters_client(void)
 
        failure = 1;
 
+       if (!CBB_init(&cbb, 0))
+               errx(1, "Failed to create CBB");
+
        if ((ssl_ctx = SSL_CTX_new(TLS_client_method())) == NULL)
                errx(1, "failed to create SSL_CTX");
        if ((ssl = SSL_new(ssl_ctx)) == NULL)
@@ -2062,9 +2065,6 @@ test_tlsext_quic_transport_parameters_client(void)
            &client_funcs, &server_funcs))
                errx(1, "failed to fetch quic transport parameter funcs");
 
-       if (!CBB_init(&cbb, 0))
-               errx(1, "Failed to create CBB");
-
        if (client_funcs->needs(ssl, SSL_TLSEXT_MSG_CH)) {
                FAIL("client should not need QUIC\n");
                goto err;
@@ -3731,6 +3731,9 @@ test_tlsext_keyshare_server(void)
 
        failure = 1;
 
+       if (!CBB_init(&cbb, 0))
+               errx(1, "Failed to create CBB");
+
        if ((ssl_ctx = SSL_CTX_new(TLS_client_method())) == NULL)
                errx(1, "failed to create SSL_CTX");
        if ((ssl = SSL_new(ssl_ctx)) == NULL)
@@ -3740,9 +3743,6 @@ test_tlsext_keyshare_server(void)
            &server_funcs))
                errx(1, "failed to fetch keyshare funcs");
 
-       if (!CBB_init(&cbb, 0))
-               errx(1, "Failed to create CBB");
-
        ssl->s3->hs.negotiated_tls_version = TLS1_2_VERSION;
        if (server_funcs->needs(ssl, SSL_TLSEXT_MSG_SH)) {
                FAIL("server should not need keyshare\n");