summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2017-12-28 12:52:45 +0000
committerjsing <>2017-12-28 12:52:45 +0000
commit634412e48e5bb8a467c81c0e1ca56c3b5b343fed (patch)
treea5cbad6eb947d586d4a72a56cfd25c08d3f8994c
parent2dd9af2510937e01b04e15965dcc685758cd61db (diff)
downloadopenbsd-634412e48e5bb8a467c81c0e1ca56c3b5b343fed.tar.gz
openbsd-634412e48e5bb8a467c81c0e1ca56c3b5b343fed.tar.bz2
openbsd-634412e48e5bb8a467c81c0e1ca56c3b5b343fed.zip
Initialise new_cipher in the serverhello TLS extensions test, to avoid a
NULL pointer dereference in ssl_using_ecc_cipher(). Some compilers avoid triggering this, likely due to the EC formats list also being NULL. While here, setup the EC formats list so that we actually include the EC points format extension in the server hello extensions. Found the hard way by bcook@
-rw-r--r--src/regress/lib/libssl/tlsext/tlsexttest.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/regress/lib/libssl/tlsext/tlsexttest.c b/src/regress/lib/libssl/tlsext/tlsexttest.c
index 6a68344506..d628299e3e 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.17 2017/11/28 16:40:21 jsing Exp $ */ 1/* $OpenBSD: tlsexttest.c,v 1.18 2017/12/28 12:52:45 jsing 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>
@@ -2835,8 +2835,9 @@ test_tlsext_clienthello_build(void)
2835unsigned char tlsext_serverhello_default[] = {}; 2835unsigned char tlsext_serverhello_default[] = {};
2836 2836
2837unsigned char tlsext_serverhello_enabled[] = { 2837unsigned char tlsext_serverhello_enabled[] = {
2838 0x00, 0x0d, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 2838 0x00, 0x13, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00,
2839 0x05, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 2839 0x05, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x02, 0x01,
2840 0x00, 0x00, 0x23, 0x00, 0x00,
2840}; 2841};
2841 2842
2842static int 2843static int
@@ -2861,6 +2862,9 @@ test_tlsext_serverhello_build(void)
2861 if ((ssl->session = SSL_SESSION_new()) == NULL) 2862 if ((ssl->session = SSL_SESSION_new()) == NULL)
2862 errx(1, "failed to create session"); 2863 errx(1, "failed to create session");
2863 2864
2865 S3I(ssl)->hs.new_cipher =
2866 ssl3_get_cipher_by_id(TLS1_CK_RSA_WITH_AES_128_SHA256);
2867
2864 if (!tlsext_serverhello_build(ssl, &cbb)) { 2868 if (!tlsext_serverhello_build(ssl, &cbb)) {
2865 FAIL("failed to build serverhello extensions\n"); 2869 FAIL("failed to build serverhello extensions\n");
2866 goto err; 2870 goto err;
@@ -2888,8 +2892,15 @@ test_tlsext_serverhello_build(void)
2888 2892
2889 /* Turn a few things on so we get extensions... */ 2893 /* Turn a few things on so we get extensions... */
2890 S3I(ssl)->send_connection_binding = 1; 2894 S3I(ssl)->send_connection_binding = 1;
2895 S3I(ssl)->hs.new_cipher =
2896 ssl3_get_cipher_by_id(TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256);
2891 ssl->internal->tlsext_status_expected = 1; 2897 ssl->internal->tlsext_status_expected = 1;
2892 ssl->internal->tlsext_ticket_expected = 1; 2898 ssl->internal->tlsext_ticket_expected = 1;
2899 if ((SSI(ssl)->tlsext_ecpointformatlist = malloc(1)) == NULL)
2900 errx(1, "malloc failed");
2901 SSI(ssl)->tlsext_ecpointformatlist_length = 1;
2902 SSI(ssl)->tlsext_ecpointformatlist[0] =
2903 TLSEXT_ECPOINTFORMAT_uncompressed;
2893 2904
2894 if (!tlsext_serverhello_build(ssl, &cbb)) { 2905 if (!tlsext_serverhello_build(ssl, &cbb)) {
2895 FAIL("failed to build serverhello extensions\n"); 2906 FAIL("failed to build serverhello extensions\n");