From 6602a2998f4cc8475b15a048d5302446c29ead80 Mon Sep 17 00:00:00 2001 From: tb Date: Fri, 29 Mar 2024 04:45:15 +0000 Subject: [PATCH] Clean up X509_VERIFY_PARAM_add0_policy() Streamline some checks and use more idiomatic sk_push() error check ok jsing --- lib/libcrypto/x509/x509_vpm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/libcrypto/x509/x509_vpm.c b/lib/libcrypto/x509/x509_vpm.c index 674c8e445cc..62d9215b4c6 100644 --- a/lib/libcrypto/x509/x509_vpm.c +++ b/lib/libcrypto/x509/x509_vpm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_vpm.c,v 1.43 2024/03/29 00:25:32 tb Exp $ */ +/* $OpenBSD: x509_vpm.c,v 1.44 2024/03/29 04:45:15 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ @@ -464,12 +464,11 @@ LCRYPTO_ALIAS(X509_VERIFY_PARAM_set_time); int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, ASN1_OBJECT *policy) { - if (!param->policies) { + if (param->policies == NULL) param->policies = sk_ASN1_OBJECT_new_null(); - if (!param->policies) - return 0; - } - if (!sk_ASN1_OBJECT_push(param->policies, policy)) + if (param->policies == NULL) + return 0; + if (sk_ASN1_OBJECT_push(param->policies, policy) <= 0) return 0; return 1; } -- 2.20.1