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

Christos Zoulas christos at zoulas.com
Mon Sep 19 19:55:44 UTC 2022


Fixed thanks!

christos

> On Sep 19, 2022, at 8:40 AM, Vincent Mihalkovic <vmihalko at redhat.com> wrote:
> 
> Hi,
> 
> 
> 
> There was probably a misunderstanding. I sent an email: https://mailman.astron.com/pipermail/file/2022-September/000856.html <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 <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 <mailto:vmihalko at redhat.com>> wrote:
> 
> Hello,
> 
> 
> 
> reproducer from https://bugzilla.redhat.com/show_bug.cgi?id=2095828 <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 <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 <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
> 
> 
> 
> 
> <compression.patch>--
> File mailing list
> File at astron.com <mailto:File at astron.com>
> https://mailman.astron.com/mailman/listinfo/file <https://mailman.astron.com/mailman/listinfo/file>
> <sanitizer.log>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.astron.com/pipermail/file/attachments/20220919/14b2253c/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <https://mailman.astron.com/pipermail/file/attachments/20220919/14b2253c/attachment.asc>


More information about the File mailing list