summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2014-08-28 13:51:39 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2014-08-28 13:51:39 +0000
commit4cebe8933e66e09c42c6c4e65bd6c9f0f003d429 (patch)
tree9e8423c5ba174ca83793192728b53550516453ad /usr.bin
parent58aa16474fe3e3af3e0f865a21f2ff039cff9eb0 (diff)
Ensure that a format option argument is a known specifier.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/openssl/apps.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.bin/openssl/apps.c b/usr.bin/openssl/apps.c
index f69613e5864..e34aeaecba3 100644
--- a/usr.bin/openssl/apps.c
+++ b/usr.bin/openssl/apps.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apps.c,v 1.5 2014/08/28 13:39:07 jsing Exp $ */
+/* $OpenBSD: apps.c,v 1.6 2014/08/28 13:51:38 jsing Exp $ */
/*
* Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
*
@@ -2259,6 +2259,7 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed)
char *arg, *p;
int ord = 0;
int i, j;
+ int fmt;
for (i = 1; i < argc; i++) {
p = arg = argv[i];
@@ -2294,7 +2295,14 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed)
break;
case OPTION_ARG_FORMAT:
- *opt->opt.value = str2fmt(argv[i]);
+ fmt = str2fmt(argv[i]);
+ if (fmt == FORMAT_UNDEF) {
+ fprintf(stderr,
+ "unknown %s '%s' for -%s\n",
+ opt->argname, argv[i], opt->name);
+ return (1);
+ }
+ *opt->opt.value = fmt;
break;
case OPTION_ARG_INT: