aboutsummaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-12-03 15:43:07 -0500
committerB. Watson <urchlay@slackware.uk>2025-12-03 15:43:07 -0500
commit7b5cf6d1679bf0fa3381fb0fdd4f10ec48a08244 (patch)
treee6e97f52c2584b901dee4913843e52e2502b885b /src/io.c
parent221a6c9726a47810fcf8760bcd286aa8f4e4f390 (diff)
downloadalftools-7b5cf6d1679bf0fa3381fb0fdd4f10ec48a08244.tar.gz
unalf: Fix -F for small input files.
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/io.c b/src/io.c
index 294751a..cc50b8b 100644
--- a/src/io.c
+++ b/src/io.c
@@ -73,14 +73,26 @@ static void sanity_check_header(long pos) {
if(compsize > (s.st_size - pos)) {
fatal = !(opts.force || opts.listonly);
- fprintf(stderr, "%s: %s: compressed size for header #%d is bigger than the rest of the file (truncated?), use -F to override.\n", fatal ? "fatal" : "warning", self, headers_read);
- if(fatal) exit(1);
+ fprintf(stderr, "%s: %s: compressed size for header #%d is bigger than the rest of the file (truncated?)", self, fatal ? "fatal" : "warning", headers_read);
+ if(fatal) {
+ fputs(", use -F to override.\n", stderr);
+ exit(1);
+ }
+ fputs("\n", stderr);
}
- if(compsize > origsize * 2) {
+ /* 0 byte input gives a 2-byte output, 1 byte input gives 4,
+ 2 bytes gives 5.
+ don't complain about these. starting with any 3 byte input,
+ the compressed size will always be under 2x the input size. */
+ if(origsize > 2 && compsize > 5 && compsize > origsize * 2) {
fatal = !(opts.force || opts.listonly);
- fprintf(stderr, "%s: %s: compressed size for header #%d is over twice the uncompressed size (corrupt?), use -F to override.\n", fatal ? "fatal": "warning", self, headers_read);
- if(fatal) exit(1);
+ fprintf(stderr, "%s: %s: compressed size for header #%d is over twice the uncompressed size (corrupt?)", self, fatal ? "fatal": "warning", headers_read);
+ if(fatal) {
+ fputs(", use -F to override.\n", stderr);
+ exit(1);
+ }
+ fputs("\n", stderr);
}
}