diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2017-02-19 20:13:45 +0100 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-02-21 14:36:00 -0500 |
commit | ded9d1076cffc912ed7c40256b6202876a2b6caa (patch) | |
tree | b72ce357689a50857207df71c419df9471669496 /apps | |
parent | 1d5936e478194798a287e165b81d27a1bcceaae8 (diff) |
Fix some more memory leaks with TXT_DB_insert.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2684)
(cherry picked from commit 0fbaef9e64fa10446aff805791befaa2b967e322)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/ca.c | 16 | ||||
-rw-r--r-- | apps/srp.c | 4 |
2 files changed, 12 insertions, 8 deletions
@@ -2063,19 +2063,26 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value) row[DB_rev_date] = NULL; row[DB_file] = OPENSSL_strdup("unknown"); + if (row[DB_type] == NULL || row[DB_file] == NULL) { + BIO_printf(bio_err, "Memory allocation failure\n"); + goto end; + } + irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row ptr"); - for (i = 0; i < DB_NUMBER; i++) { + for (i = 0; i < DB_NUMBER; i++) irow[i] = row[i]; - row[i] = NULL; - } irow[DB_NUMBER] = NULL; if (!TXT_DB_insert(db->db, irow)) { BIO_printf(bio_err, "failed to update database\n"); BIO_printf(bio_err, "TXT_DB error number %ld\n", db->db->error); + OPENSSL_free(irow); goto end; } + for (i = 0; i < DB_NUMBER; i++) + row[i] = NULL; + /* Revoke Certificate */ if (type == -1) ok = 1; @@ -2108,9 +2115,8 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value) } ok = 1; end: - for (i = 0; i < DB_NUMBER; i++) { + for (i = 0; i < DB_NUMBER; i++) OPENSSL_free(row[i]); - } return (ok); } diff --git a/apps/srp.c b/apps/srp.c index add010037c..253a3a3007 100644 --- a/apps/srp.c +++ b/apps/srp.c @@ -92,10 +92,8 @@ static int update_index(CA_DB *db, char **row) int i; irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row pointers"); - for (i = 0; i < DB_NUMBER; i++) { + for (i = 0; i < DB_NUMBER; i++) irow[i] = row[i]; - row[i] = NULL; - } irow[DB_NUMBER] = NULL; if (!TXT_DB_insert(db->db, irow)) { |