aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/x509/by_dir.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2017-04-20 15:33:42 -0400
committerRich Salz <rsalz@openssl.org>2017-04-20 15:33:42 -0400
commitc0452248ea1a59a41023a4765ef7d9825e80a62b (patch)
treeacf05d2312af49b5cc0b60f9ba38a720458fac3c /crypto/x509/by_dir.c
parent0444c52a5ff3c2c09f8d7f0f5b464e10231de032 (diff)
downloadopenssl-c0452248ea1a59a41023a4765ef7d9825e80a62b.tar.gz
Ignore dups in X509_STORE_add_*
X509_STORE_add_cert and X509_STORE_add_crl are changed to return success if the object to be added was already found in the store, rather than returning an error. Raise errors if empty or malformed files are read when loading certificates and CRLs. Remove NULL checks and allow a segv to occur. Add error handing for all calls to X509_STORE_add_c{ert|tl} Refactor these two routines into one. Bring the unit test for duplicate certificates up to date using the test framework. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2830)
Diffstat (limited to 'crypto/x509/by_dir.c')
-rw-r--r--crypto/x509/by_dir.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c
index f3a1f05428..201ed12c45 100644
--- a/crypto/x509/by_dir.c
+++ b/crypto/x509/by_dir.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2017 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
@@ -373,6 +373,13 @@ static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
ok = 1;
ret->type = tmp->type;
memcpy(&ret->data, &tmp->data, sizeof(ret->data));
+
+ /*
+ * Clear any errors that might have been raised processing empty
+ * or malformed files.
+ */
+ ERR_clear_error();
+
/*
* If we were going to up the reference count, we would need to
* do it on a perl 'type' basis