summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbeck <beck@openbsd.org>2015-09-11 18:07:06 +0000
committerbeck <beck@openbsd.org>2015-09-11 18:07:06 +0000
commit2036efe897bfb8717632f68ca42d58527be36596 (patch)
treed82072960a7d77abca797a535658996134899f9c
parentMerge the remnants of s3_enc.c into t1_enc.c. (diff)
downloadwireguard-openbsd-2036efe897bfb8717632f68ca42d58527be36596.tar.xz
wireguard-openbsd-2036efe897bfb8717632f68ca42d58527be36596.zip
fix unchecked mallocs - coverity 130454 and 130455
ok jsing@
-rw-r--r--usr.bin/openssl/ca.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/usr.bin/openssl/ca.c b/usr.bin/openssl/ca.c
index 254d551aa5b..0a02c910d9f 100644
--- a/usr.bin/openssl/ca.c
+++ b/usr.bin/openssl/ca.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ca.c,v 1.12 2015/09/11 14:30:23 bcook Exp $ */
+/* $OpenBSD: ca.c,v 1.13 2015/09/11 18:07:06 beck Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -1779,7 +1779,8 @@ again2:
if (!X509_set_version(ret, 2))
goto err;
#endif
-
+ if (ci->serialNumber == NULL)
+ goto err;
if (BN_to_ASN1_INTEGER(serial, ci->serialNumber) == NULL)
goto err;
if (selfsign) {
@@ -1929,6 +1930,11 @@ again2:
tm = X509_get_notAfter(ret);
row[DB_exp_date] = malloc(tm->length + 1);
+ if (row[DB_exp_date] == NULL) {
+ BIO_printf(bio_err, "Memory allocation failure\n");
+ goto err;
+ }
+
memcpy(row[DB_exp_date], tm->data, tm->length);
row[DB_exp_date][tm->length] = '\0';
@@ -1938,8 +1944,8 @@ again2:
row[DB_file] = malloc(8);
row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0);
- if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
- (row[DB_file] == NULL) || (row[DB_name] == NULL)) {
+ if ((row[DB_type] == NULL) || (row[DB_file] == NULL) ||
+ (row[DB_name] == NULL)) {
BIO_printf(bio_err, "Memory allocation failure\n");
goto err;
}
@@ -2177,6 +2183,10 @@ do_revoke(X509 * x509, CA_DB * db, int type, char *value)
tm = X509_get_notAfter(x509);
row[DB_exp_date] = malloc(tm->length + 1);
+ if (row[DB_exp_date] == NULL) {
+ BIO_printf(bio_err, "Memory allocation failure\n");
+ goto err;
+ }
memcpy(row[DB_exp_date], tm->data, tm->length);
row[DB_exp_date][tm->length] = '\0';
@@ -2187,8 +2197,7 @@ do_revoke(X509 * x509, CA_DB * db, int type, char *value)
/* row[DB_name] done already */
- if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
- (row[DB_file] == NULL)) {
+ if ((row[DB_type] == NULL) || (row[DB_file] == NULL)) {
BIO_printf(bio_err, "Memory allocation failure\n");
goto err;
}