From 8bb878d21591d08ed7a763825fa03abeed384c57 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 31 May 2024 01:59:23 -0400 Subject: unprotbas: stop allowing 3 filenames. --- unprotbas.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'unprotbas.c') diff --git a/unprotbas.c b/unprotbas.c index 05a5f6e..c1c0e68 100644 --- a/unprotbas.c +++ b/unprotbas.c @@ -811,9 +811,10 @@ void parse_args(int argc, char **argv) { default: invalid_args(*argv); break; } } else { + /* arg doesn't start with a -, must be a filename */ if(!input_file) open_input(*argv); - else if(!checkonly && !output_file) + else if(!checkonly && !output_filename) output_filename = *argv; else invalid_args(*argv); @@ -890,6 +891,8 @@ int main(int argc, char **argv) { } } + /* we don't open the output file until all processing is done, to + avoid leaving invalid output files if we exit on error. */ open_output(output_filename); outbytes = fwrite(data, 1, filelen, output_file); fclose(output_file); -- cgit v1.2.3