X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=apps%2Fca.c;h=4f9de5492148a180333f81ade80d36e8498ac3c0;hb=477e40b48c5a2d5f9ba597cea2f2e2eb77e9347a;hp=ef23bdd4952474141ecac3eadc0c02b9b9363d2f;hpb=50615b3c969d1cc2d4beb09f141c678bfe06382b;p=oweals%2Fopenssl.git diff --git a/apps/ca.c b/apps/ca.c index ef23bdd495..4f9de54921 100644 --- a/apps/ca.c +++ b/apps/ca.c @@ -2003,6 +2003,20 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, goto err; } + if (row[DB_name][0] == '\0') { + /* + * An empty subject! We'll use the serial number instead. If + * unique_subject is in use then we don't want different entries with + * empty subjects matching each other. + */ + OPENSSL_free(row[DB_name]); + row[DB_name] = OPENSSL_strdup(row[DB_serial]); + if (row[DB_name] == NULL) { + BIO_printf(bio_err, "Memory allocation failure\n"); + goto err; + } + } + if (db->attributes.unique_subject) { OPENSSL_STRING *crow = row; @@ -2141,11 +2155,11 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, irow = NULL; ok = 1; err: - if (irow != NULL) { + if (ok != 1) { for (i = 0; i < DB_NUMBER; i++) OPENSSL_free(row[i]); - OPENSSL_free(irow); } + OPENSSL_free(irow); if (CAname != NULL) X509_NAME_free(CAname); @@ -2353,6 +2367,11 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value) else row[DB_serial] = BN_bn2hex(bn); BN_free(bn); + if (row[DB_name] != NULL && row[DB_name][0] == '\0') { + /* Entries with empty Subjects actually use the serial number instead */ + OPENSSL_free(row[DB_name]); + row[DB_name] = OPENSSL_strdup(row[DB_serial]); + } if ((row[DB_name] == NULL) || (row[DB_serial] == NULL)) { BIO_printf(bio_err, "Memory allocation failure\n"); goto err;