diff options
author | beck <> | 2015-09-11 18:07:06 +0000 |
---|---|---|
committer | beck <> | 2015-09-11 18:07:06 +0000 |
commit | 63eec788b454a03bda0826cf41f02edb6771089c (patch) | |
tree | 5706cb5475ede3314abcd018ff5911149d68f1cc /src | |
parent | 29446567e66706a4c7b42878647dcf3b5dd69c97 (diff) | |
download | openbsd-63eec788b454a03bda0826cf41f02edb6771089c.tar.gz openbsd-63eec788b454a03bda0826cf41f02edb6771089c.tar.bz2 openbsd-63eec788b454a03bda0826cf41f02edb6771089c.zip |
fix unchecked mallocs - coverity 130454 and 130455
ok jsing@
Diffstat (limited to 'src')
-rw-r--r-- | src/usr.bin/openssl/ca.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/usr.bin/openssl/ca.c b/src/usr.bin/openssl/ca.c index 254d551aa5..0a02c910d9 100644 --- a/src/usr.bin/openssl/ca.c +++ b/src/usr.bin/openssl/ca.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ca.c,v 1.12 2015/09/11 14:30:23 bcook Exp $ */ | 1 | /* $OpenBSD: ca.c,v 1.13 2015/09/11 18:07:06 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -1779,7 +1779,8 @@ again2: | |||
1779 | if (!X509_set_version(ret, 2)) | 1779 | if (!X509_set_version(ret, 2)) |
1780 | goto err; | 1780 | goto err; |
1781 | #endif | 1781 | #endif |
1782 | 1782 | if (ci->serialNumber == NULL) | |
1783 | goto err; | ||
1783 | if (BN_to_ASN1_INTEGER(serial, ci->serialNumber) == NULL) | 1784 | if (BN_to_ASN1_INTEGER(serial, ci->serialNumber) == NULL) |
1784 | goto err; | 1785 | goto err; |
1785 | if (selfsign) { | 1786 | if (selfsign) { |
@@ -1929,6 +1930,11 @@ again2: | |||
1929 | 1930 | ||
1930 | tm = X509_get_notAfter(ret); | 1931 | tm = X509_get_notAfter(ret); |
1931 | row[DB_exp_date] = malloc(tm->length + 1); | 1932 | row[DB_exp_date] = malloc(tm->length + 1); |
1933 | if (row[DB_exp_date] == NULL) { | ||
1934 | BIO_printf(bio_err, "Memory allocation failure\n"); | ||
1935 | goto err; | ||
1936 | } | ||
1937 | |||
1932 | memcpy(row[DB_exp_date], tm->data, tm->length); | 1938 | memcpy(row[DB_exp_date], tm->data, tm->length); |
1933 | row[DB_exp_date][tm->length] = '\0'; | 1939 | row[DB_exp_date][tm->length] = '\0'; |
1934 | 1940 | ||
@@ -1938,8 +1944,8 @@ again2: | |||
1938 | row[DB_file] = malloc(8); | 1944 | row[DB_file] = malloc(8); |
1939 | row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0); | 1945 | row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0); |
1940 | 1946 | ||
1941 | if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) || | 1947 | if ((row[DB_type] == NULL) || (row[DB_file] == NULL) || |
1942 | (row[DB_file] == NULL) || (row[DB_name] == NULL)) { | 1948 | (row[DB_name] == NULL)) { |
1943 | BIO_printf(bio_err, "Memory allocation failure\n"); | 1949 | BIO_printf(bio_err, "Memory allocation failure\n"); |
1944 | goto err; | 1950 | goto err; |
1945 | } | 1951 | } |
@@ -2177,6 +2183,10 @@ do_revoke(X509 * x509, CA_DB * db, int type, char *value) | |||
2177 | 2183 | ||
2178 | tm = X509_get_notAfter(x509); | 2184 | tm = X509_get_notAfter(x509); |
2179 | row[DB_exp_date] = malloc(tm->length + 1); | 2185 | row[DB_exp_date] = malloc(tm->length + 1); |
2186 | if (row[DB_exp_date] == NULL) { | ||
2187 | BIO_printf(bio_err, "Memory allocation failure\n"); | ||
2188 | goto err; | ||
2189 | } | ||
2180 | memcpy(row[DB_exp_date], tm->data, tm->length); | 2190 | memcpy(row[DB_exp_date], tm->data, tm->length); |
2181 | row[DB_exp_date][tm->length] = '\0'; | 2191 | row[DB_exp_date][tm->length] = '\0'; |
2182 | 2192 | ||
@@ -2187,8 +2197,7 @@ do_revoke(X509 * x509, CA_DB * db, int type, char *value) | |||
2187 | 2197 | ||
2188 | /* row[DB_name] done already */ | 2198 | /* row[DB_name] done already */ |
2189 | 2199 | ||
2190 | if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) || | 2200 | if ((row[DB_type] == NULL) || (row[DB_file] == NULL)) { |
2191 | (row[DB_file] == NULL)) { | ||
2192 | BIO_printf(bio_err, "Memory allocation failure\n"); | 2201 | BIO_printf(bio_err, "Memory allocation failure\n"); |
2193 | goto err; | 2202 | goto err; |
2194 | } | 2203 | } |