summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbeck <>2020-09-14 12:33:51 +0000
committerbeck <>2020-09-14 12:33:51 +0000
commit0d65d2118b0232bebdc91dae5db25ff9bceb06c1 (patch)
tree1309eec59d1a784adaedba6a6198066d25f765b3 /src
parentcaa40998e3f59bd98e6c4fdba3b65b2348296f74 (diff)
downloadopenbsd-0d65d2118b0232bebdc91dae5db25ff9bceb06c1.tar.gz
openbsd-0d65d2118b0232bebdc91dae5db25ff9bceb06c1.tar.bz2
openbsd-0d65d2118b0232bebdc91dae5db25ff9bceb06c1.zip
Set error if we are given an NULL ctx in x509_verify, and set error
to X509_V_ERR_OUT_OF_MEM instead of UNSPECIFIED in chain_append when allocation fails. noticed by ingo@ ok tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/x509/x509_verify.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/lib/libcrypto/x509/x509_verify.c b/src/lib/libcrypto/x509/x509_verify.c
index 80af892d8a..431f5ab1bc 100644
--- a/src/lib/libcrypto/x509/x509_verify.c
+++ b/src/lib/libcrypto/x509/x509_verify.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_verify.c,v 1.5 2020/09/14 12:00:55 tb Exp $ */ 1/* $OpenBSD: x509_verify.c,v 1.6 2020/09/14 12:33:51 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2020 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2020 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -108,7 +108,7 @@ x509_verify_chain_append(struct x509_verify_chain *chain, X509 *cert,
108 X509_up_ref(cert); 108 X509_up_ref(cert);
109 if (!sk_X509_push(chain->certs, cert)) { 109 if (!sk_X509_push(chain->certs, cert)) {
110 X509_free(cert); 110 X509_free(cert);
111 *error = X509_V_ERR_UNSPECIFIED; 111 *error = X509_V_ERR_OUT_OF_MEM;
112 return 0; 112 return 0;
113 } 113 }
114 return 1; 114 return 1;
@@ -833,9 +833,7 @@ x509_verify(struct x509_verify_ctx *ctx, X509 *leaf, char *name)
833{ 833{
834 struct x509_verify_chain *current_chain; 834 struct x509_verify_chain *current_chain;
835 835
836 if (ctx == NULL) 836 if (ctx == NULL || ctx->roots == NULL || ctx->max_depth == 0) {
837 return 0;
838 if (ctx->roots == NULL || ctx->max_depth == 0) {
839 ctx->error = X509_V_ERR_INVALID_CALL; 837 ctx->error = X509_V_ERR_INVALID_CALL;
840 return 0; 838 return 0;
841 } 839 }