[File] compress: empty stdout is not an error

Vincent Mihalkovic vmihalko at redhat.com
Tue Sep 13 15:16:58 UTC 2022


Hello,

reproducer from https://bugzilla.redhat.com/show_bug.cgi?id=2095828 is
quite simple:
$ touch emptyFile
$ zip emptyFileArchive emptyFile
  adding: emptyFile (stored 0%)
$ file -z emptyFileArchive.zip
emptyFileArchive.zip: ERROR:[gzip: Read failed, No such file or directory]
(Zip archive data, at least v1.0 to extract, compression method=store)

If we consider gzip flags "-cd"
https://github.com/file/file/blob/master/src/compress.c#L134
-c: Write output on standard output;
-d: Decompress;
and run:
$ gzip -cd emptyFileArchive.zip

gzip output is, as expected, empty, but due to this condition:
https://github.com/file/file/blob/master/src/compress.c#L993
file considers gzip output to be erroneous.

To achieve expected output:
$ file -z emptyFileArchive.zip
emptyFileArchive.zip: empty (Zip archive data, at least v1.0 to extract,
compression method=store)
I propose the following patch.

best regards,
vincent mihalkovic
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.astron.com/pipermail/file/attachments/20220913/7bc594fc/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compress.patch
Type: application/x-patch
Size: 1211 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20220913/7bc594fc/attachment.bin>


More information about the File mailing list