From 5473e3119d03d079e81fec7a05edfb38c52e1342 Mon Sep 17 00:00:00 2001 From: Tim Segers Date: Fri, 23 Dec 2022 20:17:58 +0100 Subject: Improve GF input validation --- src/opendeco-cli.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/opendeco-cli.c b/src/opendeco-cli.c index e200fcd..8fb0ebd 100644 --- a/src/opendeco-cli.c +++ b/src/opendeco-cli.c @@ -60,10 +60,10 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) arguments->RMV_DIVE = arg ? atof(arg) : -1; break; case 'L': - arguments->gflow = arg ? atoi(arg) : 100; + arguments->gflow = arg ? atoi(arg) : -1; break; case 'H': - arguments->gfhigh = arg ? atoi(arg) : 100; + arguments->gfhigh = arg ? atoi(arg) : -1; break; case 'G': if (arguments->decogasses) @@ -93,6 +93,14 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) argp_failure(state, 1, 0, "Surface air pressure must be positive"); exit(ARGP_ERR_UNKNOWN); } + if (arguments->gflow <= 0) { + argp_failure(state, 1, 0, "GF Low invalid"); + exit(ARGP_ERR_UNKNOWN); + } + if (arguments->gfhigh <= 0) { + argp_failure(state, 1, 0, "GF High invalid"); + exit(ARGP_ERR_UNKNOWN); + } if (arguments->gflow > arguments->gfhigh) { argp_failure(state, 1, 0, "GF Low must not be greater than GF High"); exit(ARGP_ERR_UNKNOWN); -- cgit v1.2.3-70-g09d2