diff options
| author | B. Watson <urchlay@slackware.uk> | 2025-12-03 15:43:07 -0500 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2025-12-03 15:43:07 -0500 |
| commit | 7b5cf6d1679bf0fa3381fb0fdd4f10ec48a08244 (patch) | |
| tree | e6e97f52c2584b901dee4913843e52e2502b885b /src | |
| parent | 221a6c9726a47810fcf8760bcd286aa8f4e4f390 (diff) | |
| download | alftools-7b5cf6d1679bf0fa3381fb0fdd4f10ec48a08244.tar.gz | |
unalf: Fix -F for small input files.
Diffstat (limited to 'src')
| -rw-r--r-- | src/io.c | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -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); } } |
