summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2025-10-24 11:45:08 +0000
committertb <>2025-10-24 11:45:08 +0000
commit8c82be46a0f9e21b9defa002abd3b6d0f82f4974 (patch)
treeaf77b9b5e7dda262974ca41fea7777daee48a450
parentdc4d56b5f3d1f310b754d8e69d1b35ba3c5d17dd (diff)
downloadopenbsd-8c82be46a0f9e21b9defa002abd3b6d0f82f4974.tar.gz
openbsd-8c82be46a0f9e21b9defa002abd3b6d0f82f4974.tar.bz2
openbsd-8c82be46a0f9e21b9defa002abd3b6d0f82f4974.zip
Add some regress coverage for SSL_SESSION_dup()
ok kenjiro
-rw-r--r--src/regress/lib/libssl/asn1/asn1test.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/regress/lib/libssl/asn1/asn1test.c b/src/regress/lib/libssl/asn1/asn1test.c
index a81c502655..ad2301eace 100644
--- a/src/regress/lib/libssl/asn1/asn1test.c
+++ b/src/regress/lib/libssl/asn1/asn1test.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1test.c,v 1.13 2024/07/22 14:50:45 jsing Exp $ */ 1/* $OpenBSD: asn1test.c,v 1.14 2025/10/24 11:45:08 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014, 2016 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014, 2016 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -371,7 +371,7 @@ session_cmp(SSL_SESSION *s1, SSL_SESSION *s2)
371static int 371static int
372do_ssl_asn1_test(int test_no, struct ssl_asn1_test *sat) 372do_ssl_asn1_test(int test_no, struct ssl_asn1_test *sat)
373{ 373{
374 SSL_SESSION *sp = NULL; 374 SSL_SESSION *sp = NULL, *sp_copy = NULL;
375 unsigned char *ap, *asn1 = NULL; 375 unsigned char *ap, *asn1 = NULL;
376 const unsigned char *pp; 376 const unsigned char *pp;
377 int i, len, rv = 1; 377 int i, len, rv = 1;
@@ -440,11 +440,31 @@ do_ssl_asn1_test(int test_no, struct ssl_asn1_test *sat)
440 goto failed; 440 goto failed;
441 } 441 }
442 442
443 if ((sp_copy = SSL_SESSION_dup(sp)) == NULL) {
444 fprintf(stderr, "FAIL: test %d - session dup failed\n", test_no);
445 goto failed;
446 }
447
448 if (session_cmp(sp, sp_copy) != 0) {
449 fprintf(stderr, "FAIL: test %d - sp and sp_dup differ\n", test_no);
450 goto failed;
451 }
452
453 /*
454 * session_cmp() checks that the certs compare as equal. Part of the
455 * documented API contract is that the certs are equal as pointers.
456 */
457 if (SSL_SESSION_get0_peer(sp) != SSL_SESSION_get0_peer(sp_copy)) {
458 fprintf(stderr, "FAIL: test %d - peer certs differ\n", test_no);
459 goto failed;
460 }
461
443 rv = 0; 462 rv = 0;
444 463
445 failed: 464 failed:
446 ERR_print_errors_fp(stderr); 465 ERR_print_errors_fp(stderr);
447 SSL_SESSION_free(sp); 466 SSL_SESSION_free(sp);
467 SSL_SESSION_free(sp_copy);
448 free(asn1); 468 free(asn1);
449 469
450 return (rv); 470 return (rv);