diff options
Diffstat (limited to 'apps/lib/apps.c')
-rw-r--r-- | apps/lib/apps.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/apps/lib/apps.c b/apps/lib/apps.c index cf99ca0ebf..e8592c4880 100644 --- a/apps/lib/apps.c +++ b/apps/lib/apps.c @@ -1670,7 +1670,8 @@ int parse_yesno(const char *str, int def) * name is expected to be in the format /type0=value0/type1=value1/type2=... * where characters may be escaped by \ */ -X509_NAME *parse_name(const char *cp, long chtype, int canmulti) +X509_NAME *parse_name(const char *cp, int chtype, int canmulti, + const char *desc) { int nextismulti = 0; char *work; @@ -1678,19 +1679,22 @@ X509_NAME *parse_name(const char *cp, long chtype, int canmulti) if (*cp++ != '/') { BIO_printf(bio_err, - "name is expected to be in the format " + "%s: %s name is expected to be in the format " "/type0=value0/type1=value1/type2=... where characters may " "be escaped by \\. This name is not in that format: '%s'\n", - --cp); + opt_getprog(), desc, --cp); return NULL; } n = X509_NAME_new(); - if (n == NULL) + if (n == NULL) { + BIO_printf(bio_err, "%s: Out of memory\n", opt_getprog()); return NULL; + } work = OPENSSL_strdup(cp); if (work == NULL) { - BIO_printf(bio_err, "%s: Error copying name input\n", opt_getprog()); + BIO_printf(bio_err, "%s: Error copying %s name input\n", + opt_getprog(), desc); goto err; } @@ -1705,13 +1709,13 @@ X509_NAME *parse_name(const char *cp, long chtype, int canmulti) /* Collect the type */ while (*cp != '\0' && *cp != '=') *bp++ = *cp++; + *bp++ = '\0'; if (*cp == '\0') { BIO_printf(bio_err, - "%s: Hit end of string before finding the '='\n", - opt_getprog()); + "%s: Missing '=' after RDN type string '%s' in %s name string\n", + opt_getprog(), typestr, desc); goto err; } - *bp++ = '\0'; ++cp; /* Collect the value. */ @@ -1723,8 +1727,8 @@ X509_NAME *parse_name(const char *cp, long chtype, int canmulti) } if (*cp == '\\' && *++cp == '\0') { BIO_printf(bio_err, - "%s: Escape character at end of string\n", - opt_getprog()); + "%s: Escape character at end of %s name string\n", + opt_getprog(), desc); goto err; } } @@ -1737,22 +1741,24 @@ X509_NAME *parse_name(const char *cp, long chtype, int canmulti) /* Parse */ nid = OBJ_txt2nid(typestr); if (nid == NID_undef) { - BIO_printf(bio_err, "%s: Skipping unknown attribute \"%s\"\n", - opt_getprog(), typestr); + BIO_printf(bio_err, + "%s: Skipping unknown %s name attribute \"%s\"\n", + opt_getprog(), desc, typestr); continue; } if (*valstr == '\0') { BIO_printf(bio_err, - "%s: No value provided for Subject Attribute %s, skipped\n", - opt_getprog(), typestr); + "%s: No value provided for %s name attribute \"%s\", skipped\n", + opt_getprog(), desc, typestr); continue; } if (!X509_NAME_add_entry_by_NID(n, nid, chtype, valstr, strlen((char *)valstr), -1, ismulti ? -1 : 0)) { ERR_print_errors(bio_err); - BIO_printf(bio_err, "%s: Error adding name attribute \"/%s=%s\"\n", - opt_getprog(), typestr ,valstr); + BIO_printf(bio_err, + "%s: Error adding %s name attribute \"/%s=%s\"\n", + opt_getprog(), desc, typestr ,valstr); goto err; } } |