diff options
author | Tim Segers <tsegers@pm.me> | 2023-01-04 13:31:02 +0100 |
---|---|---|
committer | Tim Segers <tsegers@pm.me> | 2023-01-07 15:24:51 +0100 |
commit | c2ee99e9a2c34cafdacf7b24a9b413ed5846214c (patch) | |
tree | d9d5e96b2856eb94d53c87a4be642d274520322f /src/opendeco.c | |
parent | 70d7bb650ad46a4237afd27cfd595812eb040701 (diff) | |
download | opendeco-c2ee99e9a2c34cafdacf7b24a9b413ed5846214c.tar.gz |
Improve gas input validation
Diffstat (limited to 'src/opendeco.c')
-rw-r--r-- | src/opendeco.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/opendeco.c b/src/opendeco.c index fe9a1d1..04984a9 100644 --- a/src/opendeco.c +++ b/src/opendeco.c @@ -125,7 +125,11 @@ int parse_gasses(gas_t **gasses, char *str) if (!gas_str) break; - scan_gas(&deco_gasses[gas_idx], gas_str); + if (scan_gas(&deco_gasses[gas_idx], gas_str)) { + wprintf(L"Invalid gas (%s). Aborting!\n", gas_str); + exit(-1); + } + gas_idx++; } @@ -175,7 +179,11 @@ int main(int argc, char *argv[]) double dec_per_min = xsw_to_bar(msw_or_fsw(9, 30)); gas_t bottom_gas; - scan_gas(&bottom_gas, arguments.gas); + + if (scan_gas(&bottom_gas, arguments.gas)) { + wprintf(L"Invalid gas (%s). Aborting!\n", arguments.gas); + exit(-1); + } gas_t *deco_gasses; int nof_gasses = parse_gasses(&deco_gasses, arguments.decogasses); |