diff --git a/test/cmp_hdr_test.c b/test/cmp_hdr_test.c index 69f75a24e2..a00d00c46d 100644 --- a/test/cmp_hdr_test.c +++ b/test/cmp_hdr_test.c @@ -71,25 +71,30 @@ static int test_HDR_set_get_pvno(void) static int execute_HDR_get0_senderNonce_test(CMP_HDR_TEST_FIXTURE *fixture) { + int res = 0; X509_NAME *sender = X509_NAME_new(); ASN1_OCTET_STRING *sn; if (!TEST_ptr(sender)) - return 0; + goto err; X509_NAME_ADD(sender, "CN", "A common sender name"); if (!TEST_int_eq(OSSL_CMP_CTX_set1_subjectName(fixture->cmp_ctx, sender), 1)) - return 0; + goto err; if (!TEST_int_eq(ossl_cmp_hdr_init(fixture->cmp_ctx, fixture->hdr), 1)) - return 0; + goto err; sn = ossl_cmp_hdr_get0_senderNonce(fixture->hdr); if (!TEST_int_eq(ASN1_OCTET_STRING_cmp(fixture->cmp_ctx->senderNonce, sn), 0)) - return 0; + goto err; + + res = 1; +err: X509_NAME_free(sender); - return 1; + + return res; } static int test_HDR_get0_senderNonce(void) @@ -102,23 +107,28 @@ static int test_HDR_get0_senderNonce(void) static int execute_HDR_set1_sender_test(CMP_HDR_TEST_FIXTURE *fixture) { + int res = 0; X509_NAME *x509name = X509_NAME_new(); if (!TEST_ptr(x509name)) - return 0; + goto err; X509_NAME_ADD(x509name, "CN", "A common sender name"); if (!TEST_int_eq(ossl_cmp_hdr_set1_sender(fixture->hdr, x509name), 1)) - return 0; + goto err; + if (!TEST_int_eq(fixture->hdr->sender->type, GEN_DIRNAME)) - return 0; + goto err; if (!TEST_int_eq(X509_NAME_cmp(fixture->hdr->sender->d.directoryName, x509name), 0)) - return 0; + goto err; + res = 1; +err: X509_NAME_free(x509name); - return 1; + + return res; } static int test_HDR_set1_sender(void) @@ -131,24 +141,28 @@ static int test_HDR_set1_sender(void) static int execute_HDR_set1_recipient_test(CMP_HDR_TEST_FIXTURE *fixture) { + int res = 0; X509_NAME *x509name = X509_NAME_new(); if (!TEST_ptr(x509name)) - return 0; + goto err; X509_NAME_ADD(x509name, "CN", "A common recipient name"); if (!TEST_int_eq(ossl_cmp_hdr_set1_recipient(fixture->hdr, x509name), 1)) - return 0; + goto err; if (!TEST_int_eq(fixture->hdr->recipient->type, GEN_DIRNAME)) - return 0; + goto err; if (!TEST_int_eq(X509_NAME_cmp(fixture->hdr->recipient->d.directoryName, x509name), 0)) - return 0; + goto err; + res = 1; +err: X509_NAME_free(x509name); - return 1; + + return res; } static int test_HDR_set1_recipient(void) @@ -203,7 +217,7 @@ static int execute_HDR_set1_senderKID_test(CMP_HDR_TEST_FIXTURE *fixture) int res = 0; if (!TEST_ptr(senderKID)) - return 0; + goto err; if (!TEST_int_eq(ASN1_OCTET_STRING_set(senderKID, rand_data, sizeof(rand_data)), 1)) @@ -265,7 +279,7 @@ static int execute_HDR_push1_freeText_test(CMP_HDR_TEST_FIXTURE *fixture) int res = 0; if (!TEST_ptr(text)) - return 0; + goto err; if (!ASN1_STRING_set(text, "A free text", -1)) goto err; @@ -280,6 +294,7 @@ static int execute_HDR_push1_freeText_test(CMP_HDR_TEST_FIXTURE *fixture) res = 1; err: ASN1_UTF8STRING_free(text); + return res; }