Resolves: #2121694 - fix recognition of compressed empty files

This commit is contained in:
Vincent Mihalkovic 2022-08-28 22:18:23 +02:00
parent c9ddf048ab
commit 8fa5828ebd
2 changed files with 53 additions and 1 deletions

View File

@ -0,0 +1,45 @@
diff --git a/src/compress.c b/src/compress.c
index ba1e3d7..6846d66 100644
--- a/src/compress.c
+++ b/src/compress.c
@@ -932,23 +932,23 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, const unsigned char *old,
rv = OKDATA;
r = sread(fdp[STDOUT_FILENO][0], *newch, bytes_max, 0);
if (r <= 0) {
- DPRINTF("Read stdout failed %d (%s)\n", fdp[STDOUT_FILENO][0],
- r != -1 ? strerror(errno) : "no data");
-
- rv = ERRDATA;
- if (r == 0 &&
- (r = sread(fdp[STDERR_FILENO][0], *newch, bytes_max, 0)) > 0)
- {
- r = filter_error(*newch, r);
- goto ok;
- }
- free(*newch);
- if (r == 0)
- rv = makeerror(newch, n, "Read failed, %s",
- strerror(errno));
- else
- rv = makeerror(newch, n, "No data");
- goto err;
+ if (r < 0) {
+ rv = ERRDATA;
+ DPRINTF("Read stdout failed %d (%s)\n", fdp[STDOUT_FILENO][0],
+ strerror(errno));
+ goto err;
+ } else if ((r = sread(fdp[STDERR_FILENO][0], *newch, bytes_max, 0)) > 0){
+ rv = ERRDATA;
+ r = filter_error(*newch, r);
+ goto ok;
+ }
+ if (r == 0)
+ goto ok;
+ free(*newch);
+ rv = ERRDATA;
+ rv = makeerror(newch, n, "Read stderr failed, %s",
+ strerror(errno));
+ goto err;
}
ok:
*n = r;

View File

@ -15,7 +15,7 @@
Summary: Utility for determining file types
Name: file
Version: 5.39
Release: 8%{?dist}
Release: 9%{?dist}
License: BSD
Source0: http://ftp.astron.com/pub/file/file-%{version}.tar.gz
@ -32,6 +32,9 @@ Patch3: file-5.39-CLOEXEC.patch
# Upstream commit 7d9b0f0d853957ad88dae0f440fecd58d2740ca7 (#1963892)
Patch4: file-5.40-magic-python.patch
# not yet upstream
Patch5: file-5.33-fix-compression.patch
URL: https://www.darwinsys.com/file/
Requires: file-libs%{?_isa} = %{version}-%{release}
BuildRequires: zlib-devel
@ -210,6 +213,10 @@ cd %{py3dir}
%endif
%changelog
* Wed Aug 17 2022 Vincent Mihalkovic <vmihalko@redhat.com> - 5.39-9
- fix recognition (src/compress.c) of compressed empty files
Resolves: #2121694
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 5.39-8
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688