From f58234fbe744db5c5cf6bc385156f9ed28393f94 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sun, 7 Dec 2025 05:51:00 -0500 Subject: alf: fix off-by-one for "too large" message, don't clear output buffer as inc_output_len() zeroes each byte before it gets used. --- src/alf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/alf.c b/src/alf.c index 12f1608..9ffb430 100644 --- a/src/alf.c +++ b/src/alf.c @@ -200,8 +200,9 @@ void crunch_file(const char *filename_arg) { /* read in entire input, couldn't do it this way on the Atari */ input_len = fread(input_buf, 1, MAX_INPUT_SIZE - 1, in_file); - if(!feof(in_file)) { - fprintf(stderr, "%s: %s: this file is too large; only compressing the first 16MB.\n", self, in_filename); + if(input_len == MAX_INPUT_SIZE - 1) { + if(fgetc(in_file) != EOF) + fprintf(stderr, "%s: %s: this file is too large; only compressing the first 16MB.\n", self, in_filename); } if(opt_txtconv) @@ -211,8 +212,6 @@ void crunch_file(const char *filename_arg) { fstat(fileno(in_file), &in_file_stat); /* for timestamp */ fclose(in_file); - memset(output_buf, 0, sizeof(output_buf)); - create_header(); if(opt_verbose) { printf("Crunching %s as %s", in_filename, hdr_filename); -- cgit v1.2.3