aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/x509/x509_cmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/x509/x509_cmp.c')
-rw-r--r--crypto/x509/x509_cmp.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/crypto/x509/x509_cmp.c b/crypto/x509/x509_cmp.c
index e06489c3347b..d1600e1e8dda 100644
--- a/crypto/x509/x509_cmp.c
+++ b/crypto/x509/x509_cmp.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -134,9 +134,12 @@ unsigned long X509_subject_name_hash_old(X509 *x)
int X509_cmp(const X509 *a, const X509 *b)
{
int rv;
+
/* ensure hash is valid */
- X509_check_purpose((X509 *)a, -1, 0);
- X509_check_purpose((X509 *)b, -1, 0);
+ if (X509_check_purpose((X509 *)a, -1, 0) != 1)
+ return -2;
+ if (X509_check_purpose((X509 *)b, -1, 0) != 1)
+ return -2;
rv = memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH);
if (rv)