release new file-5.44 and update outputs in tests

Resolves: rhbz#2126540
This commit is contained in:
Vincent Mihalkovic 2023-01-21 14:47:28 +01:00
parent 7e68155ffb
commit 02937e1761
19 changed files with 151 additions and 129 deletions

View File

@ -1,83 +0,0 @@
From 19bf47777d0002ee884467e45e6ace702e40a4c1 Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Mon, 4 Jul 2022 17:00:51 +0000
Subject: [PATCH] PR/358: Fix width for -f - (jpalus)
---
diff --git a/src/file.c b/src/file.c
index 5300e5af8..bb058ce1e 100644
--- a/src/file.c
+++ b/src/file.c
@@ -32,7 +32,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: file.c,v 1.195 2022/06/02 15:45:43 christos Exp $")
+FILE_RCSID("@(#)$File: file.c,v 1.196 2022/07/04 17:00:51 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -506,35 +506,47 @@ unwrap(struct magic_set *ms, const char *fn)
size_t llen = 0;
int wid = 0, cwid;
int e = 0;
+ size_t fi = 0, fimax = 100;
+ char **flist = malloc(sizeof(*flist) * fimax);
- if (strcmp("-", fn) == 0) {
+ if (flist == NULL)
+out: file_err(EXIT_FAILURE, "Cannot allocate memory for file list");
+
+ if (strcmp("-", fn) == 0)
f = stdin;
- wid = 1;
- } else {
+ else {
if ((f = fopen(fn, "r")) == NULL) {
file_warn("Cannot open `%s'", fn);
return 1;
}
-
- while ((len = getline(&line, &llen, f)) > 0) {
- if (line[len - 1] == '\n')
- line[len - 1] = '\0';
- cwid = file_mbswidth(ms, line);
- if (cwid > wid)
- wid = cwid;
- }
-
- rewind(f);
}
while ((len = getline(&line, &llen, f)) > 0) {
if (line[len - 1] == '\n')
line[len - 1] = '\0';
- e |= process(ms, line, wid);
+ if (fi >= fimax) {
+ fimax += 100;
+ char **nf = realloc(flist, fimax * sizeof(*flist));
+ if (nf == NULL)
+ goto out;
+ }
+ flist[fi++] = line;
+ cwid = file_mbswidth(ms, line);
+ if (cwid > wid)
+ wid = cwid;
+ line = NULL;
+ llen = 0;
+ }
+
+ fimax = fi;
+ for (fi = 0; fi < fimax; fi++) {
+ e |= process(ms, flist[fi], wid);
+ free(flist[fi]);
}
+ free(flist);
- free(line);
- (void)fclose(f);
+ if (f != stdin)
+ (void)fclose(f);
return e;
}

119
file-5.44-compression.patch Normal file
View File

@ -0,0 +1,119 @@
diff --git a/src/compress.c b/src/compress.c
index 282f2a3..42842de 100644
--- a/src/compress.c
+++ b/src/compress.c
@@ -609,6 +609,7 @@ uncompresszlib(const unsigned char *old, unsigned char **newch,
int rc;
z_stream z;
+ DPRINTF("builtin zlib decompression\n");
z.next_in = CCAST(Bytef *, old);
z.avail_in = CAST(uint32_t, *n);
z.next_out = *newch;
@@ -650,6 +651,7 @@ uncompressbzlib(const unsigned char *old, unsigned char **newch,
int rc;
bz_stream bz;
+ DPRINTF("builtin bzlib decompression\n");
memset(&bz, 0, sizeof(bz));
rc = BZ2_bzDecompressInit(&bz, 0, 0);
if (rc != BZ_OK)
@@ -690,6 +692,7 @@ uncompressxzlib(const unsigned char *old, unsigned char **newch,
int rc;
lzma_stream xz;
+ DPRINTF("builtin xzlib decompression\n");
memset(&xz, 0, sizeof(xz));
rc = lzma_auto_decoder(&xz, UINT64_MAX, 0);
if (rc != LZMA_OK)
@@ -729,6 +732,7 @@ uncompresszstd(const unsigned char *old, unsigned char **newch,
ZSTD_inBuffer in;
ZSTD_outBuffer out;
+ DPRINTF("builtin zstd decompression\n");
if ((zstd = ZSTD_createDStream()) == NULL) {
return makeerror(newch, n, "No ZSTD decompression stream, %s",
strerror(errno));
@@ -777,6 +781,7 @@ uncompresslzlib(const unsigned char *old, unsigned char **newch,
bufp = *newch;
+ DPRINTF("builtin lzlib decompression\n");
dec = LZ_decompress_open();
if (!dec) {
return makeerror(newch, n, "unable to allocate LZ_Decoder");
@@ -833,11 +838,13 @@ makeerror(unsigned char **buf, size_t *len, const char *fmt, ...)
va_list ap;
int rv;
+ DPRINTF("Makeerror %s\n", fmt);
free(*buf);
va_start(ap, fmt);
rv = vasprintf(&msg, fmt, ap);
va_end(ap);
if (rv < 0) {
+ DPRINTF("Makeerror failed");
*buf = NULL;
*len = 0;
return NODATA;
@@ -1048,7 +1055,7 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, int nofork,
pid_t pid;
pid_t writepid = -1;
size_t i;
- ssize_t r;
+ ssize_t r, re;
char *const *args;
#ifdef HAVE_POSIX_SPAWNP
posix_spawn_file_actions_t fa;
@@ -1103,6 +1110,7 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, int nofork,
handledesc(&fa, fd, fdp);
+ DPRINTF("Executing %s\n", compr[method].argv[0]);
status = posix_spawnp(&pid, compr[method].argv[0], &fa, NULL,
args, NULL);
@@ -1128,6 +1136,7 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, int nofork,
* do not modify fdp[i][j].
*/
handledesc(NULL, fd, fdp);
+ DPRINTF("Executing %s\n", compr[method].argv[0]);
(void)execvp(compr[method].argv[0], args);
dprintf(STDERR_FILENO, "exec `%s' failed, %s",
@@ -1146,6 +1155,7 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, int nofork,
if (writepid == (pid_t)-1) {
rv = makeerror(newch, n, "Write to child failed, %s",
strerror(errno));
+ DPRINTF("Write to child failed\n");
goto err;
}
closefd(fdp[STDIN_FILENO], 1);
@@ -1153,6 +1163,7 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, int nofork,
rv = OKDATA;
r = sread(fdp[STDOUT_FILENO][0], *newch, bytes_max, 0);
+ DPRINTF("read got %zd\n", r);
if (r < 0) {
rv = ERRDATA;
DPRINTF("Read stdout failed %d (%s)\n", fdp[STDOUT_FILENO][0],
@@ -1165,15 +1176,17 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, int nofork,
* errors, otherwise we risk the child blocking and never
* exiting.
*/
+ DPRINTF("Closing stdout for bytes_max\n");
closefd(fdp[STDOUT_FILENO], 0);
goto ok;
}
- if ((r = sread(fdp[STDERR_FILENO][0], *newch, bytes_max, 0)) > 0) {
+ if ((re = sread(fdp[STDERR_FILENO][0], *newch, bytes_max, 0)) > 0) {
+ DPRINTF("Got stuff from stderr %s\n", *newch);
rv = ERRDATA;
r = filter_error(*newch, r);
goto ok;
}
- if (r == 0)
+ if (re == 0)
goto ok;
rv = makeerror(newch, n, "Read stderr failed, %s",
strerror(errno));

View File

@ -1,28 +1,27 @@
From 95c993ff6bdfe92a7f519c4db60157a421e65b38 Mon Sep 17 00:00:00 2001
From 82bed46bc78089656a28c4daca0901f7b3f409a7 Mon Sep 17 00:00:00 2001
From: Siteshwar Vashisht <svashisht@redhat.com>
Date: Thu, 21 Feb 2019 15:26:38 +0100
Subject: [PATCH] Upstream says it's up to distributions to add a way to
support local-magic.
---
magic/magic.local | 3 +++
magic/magic.local | 2 ++
src/Makefile.am | 2 +-
src/Makefile.in | 2 +-
src/apprentice.c | 2 +-
4 files changed, 6 insertions(+), 3 deletions(-)
4 files changed, 5 insertions(+), 3 deletions(-)
create mode 100644 magic/magic.local
diff --git a/magic/magic.local b/magic/magic.local
new file mode 100644
index 0000000..283a863
index 0000000..33580e4
--- /dev/null
+++ b/magic/magic.local
@@ -0,0 +1,3 @@
@@ -0,0 +1,2 @@
+# Magic local data for file(1) command.
+# Insert here your local magic data. Format is described in magic(5).
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 3f67f2c..b43cb8e 100644
index 96749b5..e3eaf36 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
@ -32,10 +31,10 @@ index 3f67f2c..b43cb8e 100644
nodist_include_HEADERS = magic.h
diff --git a/src/Makefile.in b/src/Makefile.in
index 59f3b5e..a8f56cf 100644
index 155034b..151e4a4 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -356,7 +356,7 @@ target_alias = @target_alias@
@@ -357,7 +357,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
@ -45,18 +44,18 @@ index 59f3b5e..a8f56cf 100644
nodist_include_HEADERS = magic.h
AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"'
diff --git a/src/apprentice.c b/src/apprentice.c
index 1437bcc..b609dd1 100644
index db21787..5134682 100644
--- a/src/apprentice.c
+++ b/src/apprentice.c
@@ -460,7 +460,7 @@ apprentice_1(struct magic_set *ms, const char *fn, int action)
@@ -496,7 +496,7 @@ apprentice_1(struct magic_set *ms, const char *fn, int action)
#ifndef COMPILE_ONLY
map = apprentice_map(ms, fn);
if (map == NULL) {
- if (ms->flags & MAGIC_CHECK)
+ if (ms->flags & MAGIC_CHECK && strcmp("/etc/magic", fn) != 0)
file_magwarn(ms, "using regular magic file `%s'", fn);
file_magwarn(NULL, "using regular magic file `%s'", fn);
map = apprentice_load(ms, fn, action);
if (map == NULL)
--
2.25.4
2.39.0

View File

@ -1,14 +0,0 @@
Fix use-after-free with large file -f list
diff --git a/src/file.c b/src/file.c
index bb058ce1e0082e95..a41018fc1670373c 100644
--- a/src/file.c
+++ b/src/file.c
@@ -529,6 +529,7 @@ out: file_err(EXIT_FAILURE, "Cannot allocate memory for file list");
char **nf = realloc(flist, fimax * sizeof(*flist));
if (nf == NULL)
goto out;
+ flist = nf;
}
flist[fi++] = line;
cwid = file_mbswidth(ms, line);

View File

@ -14,8 +14,8 @@
Summary: Utility for determining file types
Name: file
Version: 5.42
Release: 5%{?dist}
Version: 5.44
Release: 1%{?dist}
License: BSD
Source0: http://ftp.astron.com/pub/file/file-%{version}.tar.gz
Source1: http://ftp.astron.com/pub/file/file-%{version}.tar.gz.asc
@ -29,9 +29,8 @@ Patch0: file-localmagic.patch
Patch1: file-4.17-rpm-name.patch
Patch2: file-5.04-volume_key.patch
# Upstream commit: https://github.com/file/file/commit/19bf47777d0002ee884467e45e6ace702e40a4c1
Patch3: file-5.42-fix-stdin-input.patch
Patch4: file-rh2110622.patch
# upstream commit: https://github.com/file/file/commit/1dd21dd360472d7b830825df8e40a06cdc1cbbcf
Patch3: file-5.44-compression.patch
URL: https://www.darwinsys.com/file/
Requires: file-libs%{?_isa} = %{version}-%{release}
@ -217,6 +216,9 @@ make -C tests check
%endif
%changelog
* Fri Jan 20 2023 Vincent Mihalkovic <vmihalko@redhat.com> - 5.44-1
- update to new version 5.44
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 5.42-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

View File

@ -1,3 +1,3 @@
SHA512 (file-5.42.tar.gz) = 33c3c339a561c6cf787cc06a16444a971c62068b01827612c948207a9714107b617bed8148cd67e6280cb1c62ad4dfb1205fb8486ea9c042ce7e19b067d3bb05
SHA512 (file-5.42.tar.gz.asc) = a7105c48f6c671638f5fb7f18f9b193d108456655b4c734208e00aca36fab54dd330ec2fdc3ff29fb78adbc16874af4fb0916c560e50228f82003a8cd258491a
SHA512 (file-5.44.tar.gz) = 26c3b9c7a6950649d0b2de896bfeca54289febe4cd487c0f91aa6ff1857fa49f9077f8738a17b86100125668a31dae05b586615c564f78da47ac20a1e4a74f63
SHA512 (file-5.44.tar.gz.asc) = 1a4dc39283f4859581441aa35b3ed72b323c4e05ca0960d17126d1b9ec18465c695c0545e24f09f8437a60ab52e582be67b6cbbc656bbb676de00148c3644d23
SHA512 (christoskey.asc) = 952323eb3c0cd3ae1b6c059e301b176fd60b61c76789b96c800a995253bd8dd88182617a2358fbe09b9571cd642fd4098dd0d91152a6347669324d79b12f94ee

View File

@ -11,6 +11,7 @@ jpg/xsane-zoom-in.jpg
lnk/windows_link.lnk
mach-o/PythonLauncher
pbm/icontopbm-back-from-icon.pbm
pcd/photo_cd.pcd
so/libaio.so
tar.gz/a.tar.gz
tgz/broken-file.tgz

View File

@ -1 +1 @@
DOS executable (COM)
DOS executable (COM), start instruction 0xe98c010d 0a466169

View File

@ -1 +1 @@
PE32 executable (DLL) (GUI) Intel 80386, for MS Windows
PE32 executable (DLL) (GUI) Intel 80386, for MS Windows, 5 sections

View File

@ -1 +1 @@
Transport Neutral Encapsulation Format
Transport Neutral Encapsulation Format (TNEF), OEM codepage 1252 (checksum 0xe8), MessageAttribute "IPM.Note.Portada Newseum"

View File

@ -1 +1 @@
PE32 executable (DLL) (console) Intel 80386 (stripped to external PDB), for MS Windows
PE32 executable (DLL) (console) Intel 80386 (stripped to external PDB), for MS Windows, 10 sections

View File

@ -1 +1 @@
gzip compressed data, was "abc1", last modified: Mon May 7 22:58:26 2007, from Unix, truncated
gzip compressed data, was "abc1", last modified: Mon May 7 22:58:26 2007, from Unix, original size modulo 2^32 0

View File

@ -1 +1 @@
gzip compressed data, was "abc2", last modified: Mon May 7 22:58:26 2007, from Unix, truncated
gzip compressed data, was "abc2", last modified: Mon May 7 22:58:26 2007, from Unix, original size modulo 2^32 0

View File

@ -1 +1 @@
PE32 executable (DLL) (console) Intel 80386 Mono/.Net assembly, for MS Windows
PE32 executable (DLL) (console) Intel 80386 Mono/.Net assembly, for MS Windows, 3 sections

View File

@ -1 +1 @@
PE32 executable (console) Intel 80386 Mono/.Net assembly, for MS Windows
PE32 executable (console) Intel 80386 Mono/.Net assembly, for MS Windows, 3 sections

View File

@ -1 +0,0 @@
Kodak Photo CD image pack file , landscape mode

View File

@ -1 +1 @@
PE32 executable (GUI) Intel 80386, for MS Windows
PE32 executable (GUI) Intel 80386, for MS Windows, 4 sections

View File

@ -1 +1 @@
TIFF image data, little-endian, direntries=13, height=24, bps=8, compression=LZW, PhotometricIntepretation=BlackIsZero, width=24
TIFF image data, little-endian, direntries=13, height=24, bps=8, compression=LZW, PhotometricInterpretation=BlackIsZero, width=24

View File

@ -437,7 +437,6 @@ rlJournalStart
rlPhaseEnd
rlPhaseStartTest 'pcd'
compare 'pcd/photo_cd.pcd'
rlPhaseEnd
rlPhaseStartTest 'pdf'