aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-05-31 01:59:23 -0400
committerB. Watson <urchlay@slackware.uk>2024-05-31 02:01:41 -0400
commit8bb878d21591d08ed7a763825fa03abeed384c57 (patch)
treecd9f10cd0ec9114808470e2dfc75d3e2abac4d61
parent4fed70d72e1c085057fb2c9f92acc806306ca560 (diff)
downloadbw-atari8-tools-8bb878d21591d08ed7a763825fa03abeed384c57.tar.gz
unprotbas: stop allowing 3 filenames.
-rw-r--r--unprotbas.c5
1 files changed, 4 insertions, 1 deletions
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);