From ea1128d8fd927b10197ea55a83207a04a7b1422c Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 30 Aug 2016 14:34:59 +0000 Subject: [PATCH] Add OPTION_ARG_TIME for parsing a (64 bit if needed) time_t prodding & ok jsing --- usr.bin/openssl/apps.c | 12 +++++++++++- usr.bin/openssl/apps.h | 3 ++- usr.bin/openssl/s_time.c | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/usr.bin/openssl/apps.c b/usr.bin/openssl/apps.c index 2902fb7e992..7c8df2b3224 100644 --- a/usr.bin/openssl/apps.c +++ b/usr.bin/openssl/apps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.c,v 1.38 2016/08/26 15:04:15 deraadt Exp $ */ +/* $OpenBSD: apps.c,v 1.39 2016/08/30 14:34:59 deraadt Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -2272,6 +2272,16 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed, *opt->opt.lvalue = (long)val; break; + case OPTION_ARG_TIME: + val = strtonum(argv[i], 0, LLONG_MAX, &errstr); + if (errstr != NULL) { + fprintf(stderr, "%s %s argument for -%s\n", + errstr, opt->argname, opt->name); + return (1); + } + *opt->opt.tvalue = val; + break; + case OPTION_DISCARD: break; diff --git a/usr.bin/openssl/apps.h b/usr.bin/openssl/apps.h index 217931a4b16..4276e533f7f 100644 --- a/usr.bin/openssl/apps.h +++ b/usr.bin/openssl/apps.h @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.h,v 1.18 2016/08/30 11:30:14 deraadt Exp $ */ +/* $OpenBSD: apps.h,v 1.19 2016/08/30 14:34:59 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -294,6 +294,7 @@ struct option { OPTION_ARG_FUNC, OPTION_ARG_INT, OPTION_ARG_LONG, + OPTION_ARG_TIME, OPTION_DISCARD, OPTION_FUNC, OPTION_FLAG, diff --git a/usr.bin/openssl/s_time.c b/usr.bin/openssl/s_time.c index 6df03af41ce..a88df1bfe29 100644 --- a/usr.bin/openssl/s_time.c +++ b/usr.bin/openssl/s_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_time.c,v 1.15 2016/08/30 11:30:14 deraadt Exp $ */ +/* $OpenBSD: s_time.c,v 1.16 2016/08/30 14:34:59 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -194,7 +194,7 @@ struct option s_time_options[] = { .name = "time", .argname = "seconds", .desc = "Duration to perform timing tests for (default 30)", - .type = OPTION_ARG_INT, + .type = OPTION_ARG_TIME, .opt.tvalue = &s_time_config.maxtime, }, { -- 2.20.1