Don't crash on a missing Subject in index.txt
authorMatt Caswell <matt@openssl.org>
Fri, 19 Jan 2018 14:48:45 +0000 (14:48 +0000)
committerMatt Caswell <matt@openssl.org>
Mon, 22 Jan 2018 10:15:24 +0000 (10:15 +0000)
An index.txt entry which has an empty Subject name field will cause ca
to crash. Therefore check it when we load it to make sure its not empty.

Fixes #5109

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5114)

(cherry picked from commit 1e05c6d07ff963107286d028f6778d2ccc863a9a)

apps/ca.c

index d323ca0f182977689b56d4b2a5f887b0fd5f0d9d..633f6e3363a8ad01dc85ba184cda1d809c963248 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -666,6 +666,10 @@ end_of_options:
                 goto end;
             }
         }
                 goto end;
             }
         }
+        if (pp[DB_name][0] == '\0') {
+            BIO_printf(bio_err, "entry %d: bad Subject\n", i + 1);
+            goto end;
+        }
     }
     if (verbose) {
         TXT_DB_write(bio_out, db->db);
     }
     if (verbose) {
         TXT_DB_write(bio_out, db->db);