summaryrefslogtreecommitdiffstats
path: root/crypto/pkcs12/p12_crt.c
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2022-08-01 16:33:35 +0200
committerDr. David von Oheimb <dev@ddvo.net>2022-08-24 11:25:04 +0200
commitba9e3721febb073397248154a846f2088efd6409 (patch)
treea4aecbae0c4dffb9dbf211aa0d120c71baeb0247 /crypto/pkcs12/p12_crt.c
parent47dc828c6b652feb9cef5b0e4186d010986f197c (diff)
x509_att.c: improve error checking and reporting and coding style
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> (Merged from https://github.com/openssl/openssl/pull/18931)
Diffstat (limited to 'crypto/pkcs12/p12_crt.c')
-rw-r--r--crypto/pkcs12/p12_crt.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/crypto/pkcs12/p12_crt.c b/crypto/pkcs12/p12_crt.c
index 00c7129746..7889842b6f 100644
--- a/crypto/pkcs12/p12_crt.c
+++ b/crypto/pkcs12/p12_crt.c
@@ -17,15 +17,11 @@ static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags,
static int copy_bag_attr(PKCS12_SAFEBAG *bag, EVP_PKEY *pkey, int nid)
{
- int idx;
- X509_ATTRIBUTE *attr;
- idx = EVP_PKEY_get_attr_by_NID(pkey, nid, -1);
+ int idx = EVP_PKEY_get_attr_by_NID(pkey, nid, -1);
+
if (idx < 0)
return 1;
- attr = EVP_PKEY_get_attr(pkey, idx);
- if (!X509at_add1_attr(&bag->attrib, attr))
- return 0;
- return 1;
+ return X509at_add1_attr(&bag->attrib, EVP_PKEY_get_attr(pkey, idx)) != NULL;
}
PKCS12 *PKCS12_create_ex(const char *pass, const char *name, EVP_PKEY *pkey,