summaryrefslogtreecommitdiff
path: root/src/usr.bin/openssl/apps.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/usr.bin/openssl/apps.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c
index e5eda3f53b..fc5e2d073a 100644
--- a/src/usr.bin/openssl/apps.c
+++ b/src/usr.bin/openssl/apps.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: apps.c,v 1.2 2014/08/27 14:59:44 jsing Exp $ */ 1/* $OpenBSD: apps.c,v 1.3 2014/08/27 15:51:41 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -2253,7 +2253,9 @@ options_usage(struct option *opts)
2253int 2253int
2254options_parse(int argc, char **argv, struct option *opts, char **unnamed) 2254options_parse(int argc, char **argv, struct option *opts, char **unnamed)
2255{ 2255{
2256 const char *errstr;
2256 struct option *opt; 2257 struct option *opt;
2258 long long val;
2257 char *arg, *p; 2259 char *arg, *p;
2258 int i, j; 2260 int i, j;
2259 2261
@@ -2274,17 +2276,32 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed)
2274 if (strcmp(p, opt->name) != 0) 2276 if (strcmp(p, opt->name) != 0)
2275 continue; 2277 continue;
2276 2278
2277 switch (opt->type) { 2279 if (opt->type == OPTION_ARG ||
2278 case OPTION_ARG: 2280 opt->type == OPTION_ARG_INT) {
2279 if (++i >= argc) { 2281 if (++i >= argc) {
2280 fprintf(stderr, 2282 fprintf(stderr,
2281 "missing %s argument for -%s\n", 2283 "missing %s argument for -%s\n",
2282 opt->argname, opt->name); 2284 opt->argname, opt->name);
2283 return (1); 2285 return (1);
2284 } 2286 }
2287 }
2288
2289 switch (opt->type) {
2290 case OPTION_ARG:
2285 *opt->opt.arg = argv[i]; 2291 *opt->opt.arg = argv[i];
2286 break; 2292 break;
2287 2293
2294 case OPTION_ARG_INT:
2295 val = strtonum(argv[i], 0, INT_MAX, &errstr);
2296 if (errstr != NULL) {
2297 fprintf(stderr,
2298 "%s %s argument for -%s\n",
2299 errstr, opt->argname, opt->name);
2300 return (1);
2301 }
2302 *opt->opt.value = (int)val;
2303 break;
2304
2288 case OPTION_FLAG: 2305 case OPTION_FLAG:
2289 *opt->opt.flag = 1; 2306 *opt->opt.flag = 1;
2290 break; 2307 break;