From 94a1448a621730e108b9218dcb9c9d4b6b7ed88f Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Dec 07 2011 15:30:30 +0000 Subject: request: validate the -k and -f flags' arguments after we finish arg parsing --- diff --git a/src/getcert.c b/src/getcert.c index ae158ec..4cc7a98 100644 --- a/src/getcert.c +++ b/src/getcert.c @@ -513,10 +513,10 @@ request(const char *argv0, int argc, char **argv) nickname = talloc_strdup(globals.tctx, optarg); break; case 'k': - keyfile = ensure_pem(globals.tctx, optarg); + keyfile = optarg; break; case 'f': - certfile = ensure_pem(globals.tctx, optarg); + certfile = optarg; break; case 'g': keysize = atoi(optarg); @@ -613,6 +613,14 @@ request(const char *argv0, int argc, char **argv) nss_scheme, dbdir); } } + /* Make sure the file name is a valid location to store a PEM file. */ + if (keyfile != NULL) { + keyfile = ensure_pem(globals.tctx, keyfile); + } + /* Make sure the file name is a valid location to store a PEM file. */ + if (certfile != NULL) { + certfile = ensure_pem(globals.tctx, optarg); + } if (((dbdir != NULL) && (nickname == NULL)) || ((dbdir == NULL) && (nickname != NULL))) { printf(_("Database location or nickname specified "