aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-12-22 19:18:29 -0800
committerRob Landley <rob@landley.net>2019-12-22 23:10:43 -0600
commit35ee6fcf9ff0d5bb4fef39557f8fe4e9d8b8937e (patch)
tree5b6348fb2428f2f26d6e6a88fbcdc339e7a640b8 /toys
parent488f8507dcf4f634952f4f649e7a95d219468b83 (diff)
downloadtoybox-35ee6fcf9ff0d5bb4fef39557f8fe4e9d8b8937e.tar.gz
gzip: reject non-gzip files in zlib path.
It turns out that zlib defaults to just copying data verbatim if the input isn't in gzip format, rather than rejecting it. Explicitly add a check that zlib isn't doing that. (The toybox inflation path already errors out.) Also add the missing test.
Diffstat (limited to 'toys')
-rw-r--r--toys/lsb/gzip.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/toys/lsb/gzip.c b/toys/lsb/gzip.c
index 3038495e..049285af 100644
--- a/toys/lsb/gzip.c
+++ b/toys/lsb/gzip.c
@@ -78,6 +78,7 @@ static int do_deflate(int in_fd, int out_fd, int dd, int level)
}
if (!(gz = gzdopen(dd ? in_fd : out_fd, b))) perror_exit("gzdopen");
if (dd) {
+ if (gzdirect(gz)) error_exit("not gzip");
while ((len = gzread(gz, toybuf, sizeof(toybuf))) > 0)
if (len != writeall(out_fd, toybuf, len)) break;
} else {