summaryrefslogtreecommitdiffstats
path: root/lib/libssl/src
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2014-06-19 21:23:48 +0000
committertedu <tedu@openbsd.org>2014-06-19 21:23:48 +0000
commitb79435f2eed5753a38c8a6a0f6593ed32b81e1f4 (patch)
treefb19a4c568f2f732feb4973186a6be1677f96a49 /lib/libssl/src
parentAdd a basic regress test for __MAP_NOREPLACE. (diff)
downloadwireguard-openbsd-b79435f2eed5753a38c8a6a0f6593ed32b81e1f4.tar.xz
wireguard-openbsd-b79435f2eed5753a38c8a6a0f6593ed32b81e1f4.zip
improve error checking. set error code on error, and check malloc return.
add missing unlock in one case. ok lteo miod
Diffstat (limited to 'lib/libssl/src')
-rw-r--r--lib/libssl/src/crypto/x509/by_dir.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/libssl/src/crypto/x509/by_dir.c b/lib/libssl/src/crypto/x509/by_dir.c
index 21aa464962a..21ba0a7bc25 100644
--- a/lib/libssl/src/crypto/x509/by_dir.c
+++ b/lib/libssl/src/crypto/x509/by_dir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: by_dir.c,v 1.26 2014/06/12 15:49:31 deraadt Exp $ */
+/* $OpenBSD: by_dir.c,v 1.27 2014/06/19 21:23:48 tedu Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -241,16 +241,20 @@ add_cert_dir(BY_DIR *ctx, const char *dir, int type)
}
}
ent = malloc(sizeof(BY_DIR_ENTRY));
- if (!ent)
+ if (!ent) {
+ X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE);
return 0;
+ }
ent->dir_type = type;
ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
ent->dir = strdup(ss);
if (!ent->dir || !ent->hashes) {
+ X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE);
by_dir_entry_free(ent);
return 0;
}
if (!sk_BY_DIR_ENTRY_push(ctx->dirs, ent)) {
+ X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE);
by_dir_entry_free(ent);
return 0;
}
@@ -384,9 +388,16 @@ get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
}
if (!hent) {
hent = malloc(sizeof(BY_DIR_HASH));
+ if (!hent) {
+ X509err(X509_F_GET_CERT_BY_SUBJECT, ERR_R_MALLOC_FAILURE);
+ CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
+ ok = 0;
+ goto finish;
+ }
hent->hash = h;
hent->suffix = k;
if (!sk_BY_DIR_HASH_push(ent->hashes, hent)) {
+ X509err(X509_F_GET_CERT_BY_SUBJECT, ERR_R_MALLOC_FAILURE);
CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
free(hent);
ok = 0;