[Toybox] gunzip.c cleanup
Rob Landley
rob at landley.net
Wed Jan 3 01:28:10 PST 2018
Poking at this, did I break it or was it never particularly tested?
$ ./zcat README
zcat: unknown suffix: README
$ cat README | ./gunzip | head -n 3
Toybox: all-in-one Linux command line.
--- Getting started
$ cat README | gunzip | head -n 3
gzip: stdin: not in gzip format
I was trying to see if gzdopen(blah, "r") verifies the gzip header on
the data stream and thus fails due to being fed non-gzip data, or if the
first read() does that. (I dug up the zlib manual which says it doesn't
use the filehandle until read so won't notice if it's invalid, so
failure there is basically a malloc failure.)
Also, there's a lot of error_exit() calls when the old gzip continues to
the next argument instead:
$ cat ../README | gzip > one.gz
$ cat ../README | gzip > two.gz
$ touch one
$ sudo chattr +i one
$ gunzip one.gz two.gz
gzip: one already exists; do you wish to overwrite (y or n)? y
gzip: one: Operation not permitted
$ ls -l
total 12
-rw-rw-r-- 1 landley landley 0 Jan 3 03:22 one
-rw-rw-r-- 1 landley landley 3076 Jan 3 03:22 one.gz
-rw-rw-r-- 1 landley landley 6624 Jan 3 03:22 two
And so on...
Rob
More information about the Toybox
mailing list