summaryrefslogtreecommitdiffstats
path: root/crypto/pkcs7
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/pkcs7
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/pkcs7')
-rw-r--r--crypto/pkcs7/pk7_doit.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/crypto/pkcs7/pk7_doit.c b/crypto/pkcs7/pk7_doit.c
index 4a13070a0a..e68aaca466 100644
--- a/crypto/pkcs7/pk7_doit.c
+++ b/crypto/pkcs7/pk7_doit.c
@@ -1162,11 +1162,11 @@ ASN1_TYPE *PKCS7_get_attribute(const PKCS7_SIGNER_INFO *si, int nid)
static ASN1_TYPE *get_attribute(const STACK_OF(X509_ATTRIBUTE) *sk, int nid)
{
- int idx;
- X509_ATTRIBUTE *xa;
- idx = X509at_get_attr_by_NID(sk, nid, -1);
- xa = X509at_get_attr(sk, idx);
- return X509_ATTRIBUTE_get0_type(xa, 0);
+ int idx = X509at_get_attr_by_NID(sk, nid, -1);
+
+ if (idx < 0)
+ return NULL;
+ return X509_ATTRIBUTE_get0_type(X509at_get_attr(sk, idx), 0);
}
ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk)