From e05b89b74556c3af9a69626c276750f55ccdd4f8 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Wed, 26 Dec 2018 00:11:05 +0900 Subject: [PATCH] ungz: handle bad return from gzip --- .gitignore | 1 + Makefile | 2 +- util/ungz.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 930f035d..9fa4ca8e 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ # zlib /base/usr/include/zconf.h /base/usr/include/zlib.h +/util/ungz # binutils /base/usr/i686-pc-toaru diff --git a/Makefile b/Makefile index 82dae3a6..e8e1a93e 100644 --- a/Makefile +++ b/Makefile @@ -385,5 +385,5 @@ ext-freetype: base/lib/libtoaru_ext_freetype_fonts.so ext-cairo: base/lib/libtoaru_ext_cairo_renderer.so # Other extra stuff -fatbase/extra/ungz: util/ungz.c +util/ungz: util/ungz.c $(CC) -o $@ $< -lz diff --git a/util/ungz.c b/util/ungz.c index 409f11fb..cce8327b 100644 --- a/util/ungz.c +++ b/util/ungz.c @@ -42,6 +42,7 @@ int main(int argc, char **argv) { while (!gzeof(src)) { char buf[1024]; int r = gzread(src, buf, 1024); + if (r < 0) return 1; fwrite(buf, r, 1, dest); }