summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/regress/lib/libssl/tlsext/tlsexttest.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/regress/lib/libssl/tlsext/tlsexttest.c b/src/regress/lib/libssl/tlsext/tlsexttest.c
index 2da1b6487b..e4da328c67 100644
--- a/src/regress/lib/libssl/tlsext/tlsexttest.c
+++ b/src/regress/lib/libssl/tlsext/tlsexttest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tlsexttest.c,v 1.81 2023/04/27 10:53:58 tb Exp $ */ 1/* $OpenBSD: tlsexttest.c,v 1.82 2023/07/05 17:30:14 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2017 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2017 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> 4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org>
@@ -1774,8 +1774,11 @@ static const unsigned char tlsext_sni_client[] = {
1774 0x6c, 0x2e, 0x6f, 0x72, 0x67, 1774 0x6c, 0x2e, 0x6f, 0x72, 0x67,
1775}; 1775};
1776 1776
1777/* An empty array is an incomplete type and sizeof() is undefined. */
1777static const unsigned char tlsext_sni_server[] = { 1778static const unsigned char tlsext_sni_server[] = {
1779 0x00,
1778}; 1780};
1781static size_t tlsext_sni_server_len = 0;
1779 1782
1780static int 1783static int
1781test_tlsext_sni_client(void) 1784test_tlsext_sni_client(void)
@@ -1973,9 +1976,9 @@ test_tlsext_sni_server(void)
1973 if (!CBB_finish(&cbb, &data, &dlen)) 1976 if (!CBB_finish(&cbb, &data, &dlen))
1974 errx(1, "failed to finish CBB"); 1977 errx(1, "failed to finish CBB");
1975 1978
1976 if (dlen != sizeof(tlsext_sni_server)) { 1979 if (dlen != tlsext_sni_server_len) {
1977 FAIL("got server SNI with length %zu, " 1980 FAIL("got server SNI with length %zu, "
1978 "want length %zu\n", dlen, sizeof(tlsext_sni_server)); 1981 "want length %zu\n", dlen, tlsext_sni_server_len);
1979 goto err; 1982 goto err;
1980 } 1983 }
1981 1984
@@ -1984,14 +1987,14 @@ test_tlsext_sni_server(void)
1984 fprintf(stderr, "received:\n"); 1987 fprintf(stderr, "received:\n");
1985 hexdump(data, dlen); 1988 hexdump(data, dlen);
1986 fprintf(stderr, "test data:\n"); 1989 fprintf(stderr, "test data:\n");
1987 hexdump(tlsext_sni_server, sizeof(tlsext_sni_server)); 1990 hexdump(tlsext_sni_server, tlsext_sni_server_len);
1988 goto err; 1991 goto err;
1989 } 1992 }
1990 1993
1991 free(ssl->session->tlsext_hostname); 1994 free(ssl->session->tlsext_hostname);
1992 ssl->session->tlsext_hostname = NULL; 1995 ssl->session->tlsext_hostname = NULL;
1993 1996
1994 CBS_init(&cbs, tlsext_sni_server, sizeof(tlsext_sni_server)); 1997 CBS_init(&cbs, tlsext_sni_server, tlsext_sni_server_len);
1995 if (!client_funcs->parse(ssl, SSL_TLSEXT_MSG_SH, &cbs, &alert)) { 1998 if (!client_funcs->parse(ssl, SSL_TLSEXT_MSG_SH, &cbs, &alert)) {
1996 FAIL("failed to parse server SNI\n"); 1999 FAIL("failed to parse server SNI\n");
1997 goto err; 2000 goto err;
@@ -3186,7 +3189,7 @@ test_tlsext_srtp_server(void)
3186} 3189}
3187#endif /* OPENSSL_NO_SRTP */ 3190#endif /* OPENSSL_NO_SRTP */
3188 3191
3189unsigned char tlsext_clienthello_default[] = { 3192static const unsigned char tlsext_clienthello_default[] = {
3190 0x00, 0x34, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, 3193 0x00, 0x34, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00,
3191 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x08, 0x00, 0x1d, 3194 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x08, 0x00, 0x1d,
3192 0x00, 0x17, 0x00, 0x18, 0x00, 0x19, 0x00, 0x23, 3195 0x00, 0x17, 0x00, 0x18, 0x00, 0x19, 0x00, 0x23,
@@ -3196,7 +3199,11 @@ unsigned char tlsext_clienthello_default[] = {
3196 0x04, 0x03, 0x02, 0x01, 0x02, 0x03, 3199 0x04, 0x03, 0x02, 0x01, 0x02, 0x03,
3197}; 3200};
3198 3201
3199unsigned char tlsext_clienthello_disabled[] = {}; 3202/* An empty array is an incomplete type and sizeof() is undefined. */
3203static const unsigned char tlsext_clienthello_disabled[] = {
3204 0x00,
3205};
3206static size_t tlsext_clienthello_disabled_len = 0;
3200 3207
3201static int 3208static int
3202test_tlsext_clienthello_build(void) 3209test_tlsext_clienthello_build(void)
@@ -3287,18 +3294,18 @@ test_tlsext_clienthello_build(void)
3287 goto err; 3294 goto err;
3288 } 3295 }
3289 3296
3290 if (dlen != sizeof(tlsext_clienthello_disabled)) { 3297 if (dlen != tlsext_clienthello_disabled_len) {
3291 FAIL("got clienthello extensions with length %zu, " 3298 FAIL("got clienthello extensions with length %zu, "
3292 "want length %zu\n", dlen, 3299 "want length %zu\n", dlen,
3293 sizeof(tlsext_clienthello_disabled)); 3300 tlsext_clienthello_disabled_len);
3294 compare_data(data, dlen, tlsext_clienthello_disabled, 3301 compare_data(data, dlen, tlsext_clienthello_disabled,
3295 sizeof(tlsext_clienthello_disabled)); 3302 tlsext_clienthello_disabled_len);
3296 goto err; 3303 goto err;
3297 } 3304 }
3298 if (memcmp(data, tlsext_clienthello_disabled, dlen) != 0) { 3305 if (memcmp(data, tlsext_clienthello_disabled, dlen) != 0) {
3299 FAIL("clienthello extensions differs:\n"); 3306 FAIL("clienthello extensions differs:\n");
3300 compare_data(data, dlen, tlsext_clienthello_disabled, 3307 compare_data(data, dlen, tlsext_clienthello_disabled,
3301 sizeof(tlsext_clienthello_disabled)); 3308 tlsext_clienthello_disabled_len);
3302 goto err; 3309 goto err;
3303 } 3310 }
3304 3311