Commit ded9d107 authored by Bernd Edlinger's avatar Bernd Edlinger Committed by Rich Salz
Browse files

Fix some more memory leaks with TXT_DB_insert.



Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2684)
(cherry picked from commit 0fbaef9e)
parent 1d5936e4
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -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);
}

+1 −3
Original line number Diff line number Diff line
@@ -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)) {