[File] [PATCH] compress: empty stdout is not an error

Vincent Mihalkovic vmihalko at redhat.com
Mon Sep 19 12:40:03 UTC 2022


Hi,

There was probably a misunderstanding. I sent an email:
https://mailman.astron.com/pipermail/file/2022-September/000856.html with
patch.
If I understand correctly this commit:
https://github.com/file/file/commit/18f0474f698ef8f7247d61fc12a46c49dd7f7ed7
is a response to the mentioned email.
With your fix we now ignore any errors that might occur in gzip
decompression. For example:
$ touch x y
$ zip two_empty_files x y
$ gzip -cd two_empty_files.zip
   gzip: two_empty_files.zip.zip has more than one entry--rest ignored
$ echo $?
   2
$ file -z two_empty_files.zip
   two_empty_files.zip: empty (Zip archive data, at least v1.0 to extract,
compression method=store)

My patch (in attachment) was implementing the idea that the OK state is
when no error occurred. With this patch, output is:
$ file -z two_empty_files.zip
   z.zip: ERROR:[gzip: Stdin has more than one entry--rest ignored] (Zip
archive data, at least v1.0 to extract, compression method=store)

Amended patch in attachment.

best regards,
vincent mihalkovic

On Tue, Sep 13, 2022 at 5:16 PM Vincent Mihalkovic <vmihalko at redhat.com>
wrote:

> 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/20220919/18a8320e/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compression.patch
Type: text/x-patch
Size: 1267 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20220919/18a8320e/attachment.bin>


More information about the File mailing list