diff options
author | jsing <> | 2019-02-03 14:03:46 +0000 |
---|---|---|
committer | jsing <> | 2019-02-03 14:03:46 +0000 |
commit | 9007509db696d631ec557b9f8edca899c1f91c06 (patch) | |
tree | adcffb215d0bdcd00ad0e1a177241b3e00738ce0 | |
parent | ff9eff7aaa997af45437c105d09d9ea28502a682 (diff) | |
download | openbsd-9007509db696d631ec557b9f8edca899c1f91c06.tar.gz openbsd-9007509db696d631ec557b9f8edca899c1f91c06.tar.bz2 openbsd-9007509db696d631ec557b9f8edca899c1f91c06.zip |
Use malloc() and memcpy() the test X25519 x25519_peer_public value.
Otherwise, if tlsext_keyshare_server_build() fails we call free with a
pointer to static memory and bad things happen.
Reported by bcook@
-rw-r--r-- | src/regress/lib/libssl/tlsext/tlsexttest.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/regress/lib/libssl/tlsext/tlsexttest.c b/src/regress/lib/libssl/tlsext/tlsexttest.c index d9b048dbfc..06b855f6bb 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.27 2019/01/24 02:56:41 beck Exp $ */ | 1 | /* $OpenBSD: tlsexttest.c,v 1.28 2019/02/03 14:03:46 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> |
@@ -3269,13 +3269,16 @@ test_tlsext_keyshare_server(void) | |||
3269 | goto done; | 3269 | goto done; |
3270 | } | 3270 | } |
3271 | 3271 | ||
3272 | S3I(ssl)->hs_tls13.x25519_peer_public = bogokey; | 3272 | if ((S3I(ssl)->hs_tls13.x25519_peer_public = |
3273 | malloc(sizeof(bogokey))) == NULL) | ||
3274 | errx(1, "malloc failed"); | ||
3275 | memcpy(S3I(ssl)->hs_tls13.x25519_peer_public, bogokey, sizeof(bogokey)); | ||
3276 | |||
3273 | if (!tlsext_keyshare_server_build(ssl, &cbb)) { | 3277 | if (!tlsext_keyshare_server_build(ssl, &cbb)) { |
3274 | FAIL("server should be able to build a keyshare response"); | 3278 | FAIL("server should be able to build a keyshare response"); |
3275 | failure = 1; | 3279 | failure = 1; |
3276 | goto done; | 3280 | goto done; |
3277 | } | 3281 | } |
3278 | S3I(ssl)->hs_tls13.x25519_peer_public = NULL; | ||
3279 | 3282 | ||
3280 | if (!CBB_finish(&cbb, &data, &dlen)) { | 3283 | if (!CBB_finish(&cbb, &data, &dlen)) { |
3281 | FAIL("failed to finish CBB"); | 3284 | FAIL("failed to finish CBB"); |