From 60f9a6092dbe4a51e0b832bcf03cc95696943010 Mon Sep 17 00:00:00 2001 From: job Date: Wed, 26 Apr 2023 11:00:49 +0000 Subject: [PATCH] No need to pass around const pointer cpder2 Suggested by tb@ --- regress/lib/libcrypto/x509/x509_asn1.c | 34 ++++++++++++-------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/regress/lib/libcrypto/x509/x509_asn1.c b/regress/lib/libcrypto/x509/x509_asn1.c index c45221240b9..5dead2ac005 100644 --- a/regress/lib/libcrypto/x509/x509_asn1.c +++ b/regress/lib/libcrypto/x509/x509_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_asn1.c,v 1.3 2023/04/26 10:55:58 job Exp $ */ +/* $OpenBSD: x509_asn1.c,v 1.4 2023/04/26 11:00:49 job Exp $ */ /* * Copyright (c) 2023 Job Snijders * @@ -31,7 +31,7 @@ static void x509_setup(unsigned char **der, unsigned char **der2, X509 **x, - const unsigned char **cpder2, long dersz, long *der2sz) + long dersz, long *der2sz) { const unsigned char *cpder; @@ -40,7 +40,6 @@ x509_setup(unsigned char **der, unsigned char **der2, X509 **x, errx(1, "d2i_X509"); if ((*der2sz = i2d_X509(*x, der2)) <= 0) errx(1, "i2d_X509"); - *cpder2 = *der2; } static void @@ -127,7 +126,6 @@ main(void) EVP_PKEY *pkey = NULL; EVP_PKEY_CTX *pkey_ctx = NULL; X509 *a, *x; - const unsigned char *cpder2; unsigned char *der = NULL, *der2 = NULL; long dersz, der2sz; int ret = 0; @@ -159,51 +157,51 @@ main(void) errx(1, "i2d_X509"); /* test X509_set_version */ - x509_setup(&der, &der2, &a, &cpder2, dersz, &der2sz); + x509_setup(&der, &der2, &a, dersz, &der2sz); if (!X509_set_version(a, 2)) errx(1, "X509_set_version"); - ret += x509_compare("X509_set_version", a, cpder2, der2sz); + ret += x509_compare("X509_set_version", a, der2, der2sz); x509_cleanup(&a, &der2); /* test X509_set_serialNumber */ - x509_setup(&der, &der2, &a, &cpder2, dersz, &der2sz); + x509_setup(&der, &der2, &a, dersz, &der2sz); x509_set_integer(X509_set_serialNumber, &a, 2); - ret += x509_compare("X509_set_serialNumber", a, cpder2, der2sz); + ret += x509_compare("X509_set_serialNumber", a, der2, der2sz); x509_cleanup(&a, &der2); /* test X509_set_issuer_name */ - x509_setup(&der, &der2, &a, &cpder2, dersz, &der2sz); + x509_setup(&der, &der2, &a, dersz, &der2sz); x509_set_name(X509_set_issuer_name, &a, "DE"); - ret += x509_compare("X509_set_issuer_name", a, cpder2, der2sz); + ret += x509_compare("X509_set_issuer_name", a, der2, der2sz); x509_cleanup(&a, &der2); /* test X509_set_subject_name */ - x509_setup(&der, &der2, &a, &cpder2, dersz, &der2sz); + x509_setup(&der, &der2, &a, dersz, &der2sz); x509_set_name(X509_set_subject_name, &a, "FR"); - ret += x509_compare("X509_set_subject_name", a, cpder2, der2sz); + ret += x509_compare("X509_set_subject_name", a, der2, der2sz); x509_cleanup(&a, &der2); /* test X509_set_notBefore */ - x509_setup(&der, &der2, &a, &cpder2, dersz, &der2sz); + x509_setup(&der, &der2, &a, dersz, &der2sz); x509_set_time(X509_set_notBefore, &a, 120); - ret += x509_compare("X509_set_notBefore", a, cpder2, der2sz); + ret += x509_compare("X509_set_notBefore", a, der2, der2sz); x509_cleanup(&a, &der2); /* test X509_set_notAfter */ - x509_setup(&der, &der2, &a, &cpder2, dersz, &der2sz); + x509_setup(&der, &der2, &a, dersz, &der2sz); x509_set_time(X509_set_notAfter, &a, 180); - ret += x509_compare("X509_set_notAfter", a, cpder2, der2sz); + ret += x509_compare("X509_set_notAfter", a, der2, der2sz); x509_cleanup(&a, &der2); /* test X509_set_pubkey */ - x509_setup(&der, &der2, &a, &cpder2, dersz, &der2sz); + x509_setup(&der, &der2, &a, dersz, &der2sz); if (EVP_PKEY_keygen(pkey_ctx, &pkey) <= 0) errx(1, "EVP_PKEY_keygen"); if (X509_set_pubkey(a, pkey) != 1) errx(1, "X509_set_pubkey"); EVP_PKEY_CTX_free(pkey_ctx); EVP_PKEY_free(pkey); - ret += x509_compare("X509_set_pubkey", a, cpder2, der2sz); + ret += x509_compare("X509_set_pubkey", a, der2, der2sz); x509_cleanup(&a, &der2); if (ret) -- 2.20.1