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:19:55 +0000 (10:19 +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/5115)

apps/ca.c

index df08581e3777910ebad314e704b12791236e9b68..bde3e4438a8142cfe64956fccbddc78573a5fae7 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -880,6 +880,10 @@ int MAIN(int argc, char **argv)
             }
             p++;
         }
+        if (pp[DB_name][0] == '\0') {
+            BIO_printf(bio_err, "entry %d: bad Subject\n", i + 1);
+            goto err;
+        }
     }
     if (verbose) {
         BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT); /* cannot fail */