From: tb Date: Wed, 11 Oct 2023 13:10:13 +0000 (+0000) Subject: Rewrite X509_ALGOR_get0() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=449ce39a6f2eda3b3cd648782766c0c73688faec;p=openbsd Rewrite X509_ALGOR_get0() Make the logic slightly less convoluted. Preserve the behavior that *ppval remains unset if pptype == NULL for now. However, ensure that *ppval is set to NULL if pptype is V_ASN1_UNDER. ok jsing --- diff --git a/lib/libcrypto/asn1/x_algor.c b/lib/libcrypto/asn1/x_algor.c index 092ad80d2dc..47bde7b97e2 100644 --- a/lib/libcrypto/asn1/x_algor.c +++ b/lib/libcrypto/asn1/x_algor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_algor.c,v 1.27 2023/10/11 13:05:18 tb Exp $ */ +/* $OpenBSD: x_algor.c,v 1.28 2023/10/11 13:10:13 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -176,20 +176,26 @@ X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval) } void -X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype, const void **ppval, - const X509_ALGOR *algor) +X509_ALGOR_get0(const ASN1_OBJECT **out_aobj, int *out_type, + const void **out_value, const X509_ALGOR *alg) { - if (paobj) - *paobj = algor->algorithm; - if (pptype) { - if (algor->parameter == NULL) { - *pptype = V_ASN1_UNDEF; - return; - } else - *pptype = algor->parameter->type; - if (ppval) - *ppval = algor->parameter->value.ptr; + int type = V_ASN1_UNDEF; + const void *value = NULL; + + if (out_aobj != NULL) + *out_aobj = alg->algorithm; + + if (out_type == NULL) + return; + + if (alg->parameter != NULL) { + type = alg->parameter->type; + value = alg->parameter->value.ptr; } + + *out_type = type; + if (out_value != NULL) + *out_value = value; } int