diff options
| -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); } } |
