release new file-5.45 and update tests

Resolves: rhbz#2227099
This commit is contained in:
Vincent Mihalkovic 2023-07-31 14:04:10 +02:00
parent ff7309f583
commit 8717428e9e
28 changed files with 194 additions and 155 deletions

View File

@ -1,119 +0,0 @@
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,25 +0,0 @@
diff --git a/src/readelf.c b/src/readelf.c
index 97d1451..f6e3bec 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -62,7 +62,6 @@ file_private uint64_t getu64(int, uint64_t);
#define MAX_PHNUM 128
#define MAX_SHNUM 32768
-#define MAX_SHSIZE (64 * 1024 * 1024)
#define SIZE_UNKNOWN CAST(off_t, -1)
file_private int
@@ -1453,12 +1452,6 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
return -1;
return 0;
}
- if (xsh_size > MAX_SHSIZE) {
- file_error(ms, errno, "Note section size too "
- "big (%ju > %u)", (uintmax_t)xsh_size,
- MAX_SHSIZE);
- return -1;
- }
if ((nbuf = malloc(xsh_size)) == NULL) {
file_error(ms, errno, "Cannot allocate memory"
" for note");

View File

@ -0,0 +1,103 @@
diff --git a/doc/file.man b/doc/file.man
index bf78c0c..a0a363c 100644
--- a/doc/file.man
+++ b/doc/file.man
@@ -340,12 +340,12 @@ never read them.
.It Fl P , Fl Fl parameter Ar name=value
Set various parameter limits.
.Bl -column "elf_phnum" "Default" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
+.Bl -column "elf_phnum" "Default" "XXXXXXXXXXXXXXXXXXXXXXXXXXX" -offset indent
.It Sy "Name" Ta Sy "Default" Ta Sy "Explanation"
.It Li bytes Ta 1M Ta max number of bytes to read from file
.It Li elf_notes Ta 256 Ta max ELF notes processed
.It Li elf_phnum Ta 2K Ta max ELF program sections processed
.It Li elf_shnum Ta 32K Ta max ELF sections processed
-.It Li elf_shsize Ta 128MB Ta max ELF section size processed
.It Li encoding Ta 65K Ta max number of bytes to determine encoding
.It Li indir Ta 50 Ta recursion limit for indirect magic
.It Li name Ta 50 Ta use count limit for name/use magic
diff --git a/src/apprentice.c b/src/apprentice.c
index 7907841..1d862df 100644
--- a/src/apprentice.c
+++ b/src/apprentice.c
@@ -577,7 +577,6 @@ file_ms_alloc(int flags)
ms->indir_max = FILE_INDIR_MAX;
ms->name_max = FILE_NAME_MAX;
ms->elf_shnum_max = FILE_ELF_SHNUM_MAX;
- ms->elf_shsize_max = FILE_ELF_SHSIZE_MAX;
ms->elf_phnum_max = FILE_ELF_PHNUM_MAX;
ms->elf_notes_max = FILE_ELF_NOTES_MAX;
ms->regex_max = FILE_REGEX_MAX;
diff --git a/src/file.c b/src/file.c
index 31c1035..4fa275c 100644
--- a/src/file.c
+++ b/src/file.c
@@ -156,8 +156,6 @@ file_private struct {
MAGIC_PARAM_ELF_PHNUM_MAX, 0 },
{ "elf_shnum", 0, FILE_ELF_SHNUM_MAX, "max ELF sections processed",
MAGIC_PARAM_ELF_SHNUM_MAX, 0 },
- { "elf_shsize", 0, FILE_ELF_SHSIZE_MAX, "max ELF section size",
- MAGIC_PARAM_ELF_SHSIZE_MAX, 0 },
{ "encoding", 0, FILE_ENCODING_MAX, "max bytes to scan for encoding",
MAGIC_PARAM_ENCODING_MAX, 0 },
{ "indir", 0, FILE_INDIR_MAX, "recursion limit for indirection",
diff --git a/src/file.h b/src/file.h
index 78f574e..049ef3c 100644
--- a/src/file.h
+++ b/src/file.h
@@ -492,14 +492,12 @@ struct magic_set {
uint16_t regex_max;
size_t bytes_max; /* number of bytes to read from file */
size_t encoding_max; /* bytes to look for encoding */
- size_t elf_shsize_max;
#ifndef FILE_BYTES_MAX
# define FILE_BYTES_MAX (7 * 1024 * 1024)/* how much of the file to look at */
#endif /* above 0x6ab0f4 map offset for HelveticaNeue.dfont */
#define FILE_ELF_NOTES_MAX 256
#define FILE_ELF_PHNUM_MAX 2048
#define FILE_ELF_SHNUM_MAX 32768
-#define FILE_ELF_SHSIZE_MAX (128 * 1024 * 1024)
#define FILE_INDIR_MAX 50
#define FILE_NAME_MAX 50
#define FILE_REGEX_MAX 8192
diff --git a/src/magic.c b/src/magic.c
index 052f997..5084dcc 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -625,9 +625,6 @@ magic_setparam(struct magic_set *ms, int param, const void *val)
case MAGIC_PARAM_ELF_SHNUM_MAX:
ms->elf_shnum_max = CAST(uint16_t, *CAST(const size_t *, val));
return 0;
- case MAGIC_PARAM_ELF_SHSIZE_MAX:
- ms->elf_shsize_max = *CAST(const size_t *, val);
- return 0;
case MAGIC_PARAM_ELF_NOTES_MAX:
ms->elf_notes_max = CAST(uint16_t, *CAST(const size_t *, val));
return 0;
@@ -664,9 +661,6 @@ magic_getparam(struct magic_set *ms, int param, void *val)
case MAGIC_PARAM_ELF_SHNUM_MAX:
*CAST(size_t *, val) = ms->elf_shnum_max;
return 0;
- case MAGIC_PARAM_ELF_SHSIZE_MAX:
- *CAST(size_t *, val) = ms->elf_shsize_max;
- return 0;
case MAGIC_PARAM_ELF_NOTES_MAX:
*CAST(size_t *, val) = ms->elf_notes_max;
return 0;
diff --git a/src/readelf.c b/src/readelf.c
index a2a66dd..71c0ad1 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -1450,12 +1450,6 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
return -1;
return 0;
}
- if (xsh_size > ms->elf_shsize_max) {
- file_error(ms, errno, "Note section size too "
- "big (%ju > %zu)", (uintmax_t)xsh_size,
- ms->elf_shsize_max);
- return -1;
- }
if ((nbuf = malloc(xsh_size)) == NULL) {
file_error(ms, errno, "Cannot allocate memory"
" for note");

36
file-5.45-time-t.patch Normal file
View File

@ -0,0 +1,36 @@
From 218fdf813fd5ccecbb8887a1b62509cd1c6dd3a1 Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Fri, 28 Jul 2023 14:38:25 +0000
Subject: [PATCH] deal with 32 bit time_t
---
src/file.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/file.h b/src/file.h
index 2e0494d2f..78f574ea1 100644
--- a/src/file.h
+++ b/src/file.h
@@ -27,7 +27,7 @@
*/
/*
* file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.247 2023/07/27 19:40:22 christos Exp $
+ * @(#)$File: file.h,v 1.248 2023/07/28 14:38:25 christos Exp $
*/
#ifndef __file_h__
@@ -159,9 +159,11 @@
/*
* Dec 31, 23:59:59 9999
* we need to make sure that we don't exceed 9999 because some libc
- * implementations like muslc crash otherwise
+ * implementations like muslc crash otherwise. If you are unlucky
+ * to be running on a system with a 32 bit time_t, then it is even less.
*/
-#define MAX_CTIME CAST(time_t, 0x3afff487cfULL)
+#define MAX_CTIME \
+ CAST(time_t, sizeof(time_t) > 4 ? 0x3afff487cfULL : 0x7fffffffULL)
#define FILE_BADSIZE CAST(size_t, ~0ul)
#define MAXDESC 64 /* max len of text description/MIME type */

View File

@ -14,8 +14,8 @@
Summary: Utility for determining file types
Name: file
Version: 5.44
Release: 5%{?dist}
Version: 5.45
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
@ -31,11 +31,13 @@ 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/1dd21dd360472d7b830825df8e40a06cdc1cbbcf
Patch3: file-5.44-compression.patch
# revert upstream commits (rhbz#2167964)
# 1. https://github.com/file/file/commit/e1233247bbe4d2d66b891224336a23384a93cce1
# 2. https://github.com/file/file/commit/f7a65dbf1739a8f8671621e41c5648d1f7e9f6ae
Patch3: file-5.45-readelf-limit-revert.patch
# revert upstream commit: https://github.com/file/file/commit/e1233247bbe4d2d66b891224336a23384a93cce1
Patch4: file-5.44-readelf-limit-revert.patch
# upstream commit: https://github.com/file/file/commit/218fdf813fd5ccecbb8887a1b62509cd1c6dd3a1
Patch4: file-5.45-time-t.patch
URL: https://www.darwinsys.com/file/
Requires: file-libs%{?_isa} = %{version}-%{release}
@ -221,6 +223,9 @@ make -C tests check
%endif
%changelog
* Mon Jul 31 2023 Vincent Mihalkovic <vmihalko@redhat.com> - 5.45-1
- new upstream release 5.45
* Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 5.44-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

View File

@ -1,2 +1,2 @@
SHA512 (file-5.44.tar.gz) = 26c3b9c7a6950649d0b2de896bfeca54289febe4cd487c0f91aa6ff1857fa49f9077f8738a17b86100125668a31dae05b586615c564f78da47ac20a1e4a74f63
SHA512 (file-5.44.tar.gz.asc) = 1a4dc39283f4859581441aa35b3ed72b323c4e05ca0960d17126d1b9ec18465c695c0545e24f09f8437a60ab52e582be67b6cbbc656bbb676de00148c3644d23
SHA512 (file-5.45.tar.gz) = 12611a59ff766c22a55db4b4a9f80f95a0a2e916a1d8593612c6ead32c247102a8fdc23693c6bf81bda9b604d951a62c0051e91580b1b79e190a3504c0efc20a
SHA512 (file-5.45.tar.gz.asc) = 56bf131b2f35e896788be19b4d8cd1c7ec942c794fb584d5e589375d22fbccebdd04c03e779fafc0c10840586dc41e64251b3de1767ae9ab95f5d3300f9af254

View File

@ -10,6 +10,7 @@ img/qcow2.img
jpg/xsane-zoom-in.jpg
lnk/windows_link.lnk
mach-o/PythonLauncher
misc/scc-text
pbm/icontopbm-back-from-icon.pbm
pcd/photo_cd.pcd
so/libaio.so

Binary file not shown.

View File

@ -0,0 +1,3 @@
AUTHOR: Christian Herdtweck <christian.herdtweck@intra2net.com>
URL: Created it myself
LICENSE: public domain

Binary file not shown.

View File

@ -0,0 +1,3 @@
AUTHOR: Christian Herdtweck <christian.herdtweck@intra2net.com>
URL: Created it myself
LICENSE: public domain

Binary file not shown.

View File

@ -0,0 +1,3 @@
AUTHOR: Christian Herdtweck <christian.herdtweck@intra2net.com>
URL: Created it myself
LICENSE: public domain

Binary file not shown.

View File

@ -0,0 +1,3 @@
AUTHOR: Christian Herdtweck <christian.herdtweck@intra2net.com>
URL: Created it myself
LICENSE: public domain

Binary file not shown.

View File

@ -0,0 +1,3 @@
AUTHOR: Christian Herdtweck <christian.herdtweck@intra2net.com>
URL: Created it myself
LICENSE: public domain

Binary file not shown.

View File

@ -0,0 +1,3 @@
AUTHOR: Christian Herdtweck <christian.herdtweck@intra2net.com>
URL: Created it myself
LICENSE: public domain

View File

@ -1 +1 @@
Debian binary package (format 2.0), with control.tar.gz, data compression gz
Debian binary package (format 2.0), with control.tar.gz , data compression gz

View File

@ -1 +1 @@
ASCII text
JavaScript source, ASCII text

View File

@ -0,0 +1 @@
Microsoft OneNote

View File

@ -0,0 +1 @@
Microsoft OneNote

View File

@ -0,0 +1 @@
Microsoft OneNote

View File

@ -0,0 +1 @@
Microsoft Cabinet archive data, OneNote Package, 2620 bytes, 2 files, at 0x2c last modified Sun, Feb 14 2023 13:36:38 +A "Neuer Abschnitt 1.one" last modified Sun, Nov 05 1981 00:00:00 "Notizbuch \303\266ffnen.onetoc2", number 1, 1 datablock, 0x1203 compression

View File

@ -0,0 +1 @@
Microsoft OneNote Revision Store File

View File

@ -0,0 +1 @@
Microsoft OneNote Revision Store File

View File

@ -374,7 +374,6 @@ rlJournalStart
compare 'misc/p_clear'
compare 'misc/p_pass'
compare 'misc/RPM-GPG-KEY-fedora-14-primary'
compare 'misc/scc-text'
compare 'misc/selinux_policy'
compare 'misc/zeros'
rlPhaseEnd
@ -429,6 +428,21 @@ rlJournalStart
compare 'ogg/fiba1.ogg'
rlPhaseEnd
rlPhaseStartTest 'one'
compare 'one/NewSection2007.one'
compare 'one/NewSection2010.one'
compare 'one/NewSection2016.one'
rlPhaseEnd
rlPhaseStartTest 'onepkg'
compare 'onepkg/minimal-sample-2007.onepkg'
rlPhaseEnd
rlPhaseStartTest 'onetoc2'
compare 'onetoc2/OpenNote2007.onetoc2'
compare 'onetoc2/OpenNote2016.onetoc2'
rlPhaseEnd
rlPhaseStartTest 'patch'
compare 'patch/a.patch'
compare 'patch/b.patch'