From 091909b5525fdf6833ff8e0b0d1f48ee73d0ec0c Mon Sep 17 00:00:00 2001 From: ckolivas Date: Tue, 15 Mar 2011 10:40:14 +1100 Subject: [PATCH] Refuse to compress a file smaller than a minimum size. --- rzip.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rzip.c b/rzip.c index ae17097..98a55e6 100644 --- a/rzip.c +++ b/rzip.c @@ -689,6 +689,8 @@ static void mmap_stdin(rzip_control *control, uchar *buf, struct rzip_state *st) total += ret; if (ret == 0) { /* Should be EOF */ + if (total < 128) + failure("Will not compress a tiny file\n"); print_maxverbose("Shrinking chunk to %lld\n", total); buf = (uchar *)mremap(buf, st->chunk_size, total, 0); if (unlikely(buf == MAP_FAILED)) @@ -785,6 +787,8 @@ void rzip_fd(rzip_control *control, int fd_in, int fd_out) if (!STDIN) { len = control->st_size = s.st_size; + if (len < 128) + failure("Will not compress a tiny file\n"); print_verbose("File size: %lld\n", len); } else control->st_size = 0;