diff options
| author | schwarze <> | 2021-11-03 13:27:28 +0000 |
|---|---|---|
| committer | schwarze <> | 2021-11-03 13:27:28 +0000 |
| commit | da3b2c27a37246babeffd551a8c0b1baf8ed6077 (patch) | |
| tree | af855ce4a8080ed282fb181a0f6314c48d088230 /src/lib/libcrypto/x509/x509_req.c | |
| parent | 58bd2af46ff3ae9ab817a2ddaa918a3ddc1ca939 (diff) | |
| download | openbsd-da3b2c27a37246babeffd551a8c0b1baf8ed6077.tar.gz openbsd-da3b2c27a37246babeffd551a8c0b1baf8ed6077.tar.bz2 openbsd-da3b2c27a37246babeffd551a8c0b1baf8ed6077.zip | |
Some cleanup in X509_REQ_get_extensions(3), no functional change.
In this function, merge everything that is worth merging
from the OpenSSL 1.1.1 branch, which is still under a free license,
mostly the relevant part of commit 9b0a4531 Mar 14 23:48:47 2015 +0000
to use X509_ATTRIBUTE_get0_type(3) rather than re-implementing it.
While here,
* use d2i_X509_EXTENSIONS(3) rather than ASN1_item_d2i(3);
* test pointers explicitly against NULL, not with '!', as suggested by tb@;
* drop some useless parentheses as suggested by tb@.
OK tb@
Diffstat (limited to 'src/lib/libcrypto/x509/x509_req.c')
| -rw-r--r-- | src/lib/libcrypto/x509/x509_req.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/lib/libcrypto/x509/x509_req.c b/src/lib/libcrypto/x509/x509_req.c index cbf731cc5a..e7f871449f 100644 --- a/src/lib/libcrypto/x509/x509_req.c +++ b/src/lib/libcrypto/x509/x509_req.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: x509_req.c,v 1.25 2021/11/03 12:53:25 schwarze Exp $ */ | 1 | /* $OpenBSD: x509_req.c,v 1.26 2021/11/03 13:27:28 schwarze Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -212,24 +212,20 @@ X509_REQ_get_extensions(X509_REQ *req) | |||
| 212 | int idx, *pnid; | 212 | int idx, *pnid; |
| 213 | const unsigned char *p; | 213 | const unsigned char *p; |
| 214 | 214 | ||
| 215 | if ((req == NULL) || (req->req_info == NULL) || !ext_nids) | 215 | if (req == NULL || req->req_info == NULL || ext_nids == NULL) |
| 216 | return (NULL); | 216 | return NULL; |
| 217 | for (pnid = ext_nids; *pnid != NID_undef; pnid++) { | 217 | for (pnid = ext_nids; *pnid != NID_undef; pnid++) { |
| 218 | idx = X509_REQ_get_attr_by_NID(req, *pnid, -1); | 218 | idx = X509_REQ_get_attr_by_NID(req, *pnid, -1); |
| 219 | if (idx == -1) | 219 | if (idx == -1) |
| 220 | continue; | 220 | continue; |
| 221 | attr = X509_REQ_get_attr(req, idx); | 221 | attr = X509_REQ_get_attr(req, idx); |
| 222 | if (attr->single) | 222 | ext = X509_ATTRIBUTE_get0_type(attr, 0); |
| 223 | ext = attr->value.single; | ||
| 224 | else if (sk_ASN1_TYPE_num(attr->value.set)) | ||
| 225 | ext = sk_ASN1_TYPE_value(attr->value.set, 0); | ||
| 226 | break; | 223 | break; |
| 227 | } | 224 | } |
| 228 | if (!ext || (ext->type != V_ASN1_SEQUENCE)) | 225 | if (ext == NULL || ext->type != V_ASN1_SEQUENCE) |
| 229 | return NULL; | 226 | return NULL; |
| 230 | p = ext->value.sequence->data; | 227 | p = ext->value.sequence->data; |
| 231 | return (STACK_OF(X509_EXTENSION) *)ASN1_item_d2i(NULL, &p, | 228 | return d2i_X509_EXTENSIONS(NULL, &p, ext->value.sequence->length); |
| 232 | ext->value.sequence->length, &X509_EXTENSIONS_it); | ||
| 233 | } | 229 | } |
| 234 | 230 | ||
| 235 | /* | 231 | /* |
