Skip to content

Commit 898adce

Browse files
add checks and switch to x509v3_cache_extensions
1 parent 943da00 commit 898adce

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

crypto/x509/x509_set.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include <openssl/obj.h>
6161
#include <openssl/x509.h>
6262

63+
#include "../x509v3/internal.h"
6364
#include "internal.h"
6465
#include "openssl/x509v3.h"
6566

@@ -259,10 +260,14 @@ static int X509_SIG_INFO_get(const X509_SIG_INFO *sig_info, int *digest_nid,
259260

260261
int X509_get_signature_info(X509 *x509, int *digest_nid, int *pubkey_nid,
261262
int *sec_bits, uint32_t *flags) {
262-
if (!X509_check_purpose(x509, -1, -1)) {
263+
if (x509 == NULL) {
264+
OPENSSL_PUT_ERROR(X509, ERR_R_PASSED_NULL_PARAMETER);
265+
}
266+
if(!x509v3_cache_extensions(x509)) {
263267
OPENSSL_PUT_ERROR(X509, X509_V_ERR_INVALID_PURPOSE);
264268
return 0;
265269
}
270+
266271
return X509_SIG_INFO_get(&x509->sig_info, digest_nid, pubkey_nid, sec_bits,
267272
flags);
268273
}

crypto/x509v3/v3_purp.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ static int xp_cmp(const X509_PURPOSE *const *a, const X509_PURPOSE *const *b) {
132132

133133
// As much as I'd like to make X509_check_purpose use a "const" X509* I
134134
// really can't because it does recalculate hashes and do other non-const
135-
// things.
135+
// things. If |id| is -1 it just calls |x509v3_cache_extensions| for its
136+
// side-effect.
137+
// Returns 1 on success, 0 if x does not allow purpose, -1 on (internal) error.
136138
int X509_check_purpose(X509 *x, int id, int ca) {
137139
int idx;
138140
const X509_PURPOSE *pt;

0 commit comments

Comments
 (0)