- update to 5.43:

* Add octal indirect magic
  * avoid infinite loop in non-wide code 
  * Obey MAGIC_CONTINUE with multiple magic files
  * Fix bug with large flist
  * PR/364: Detect non-nul-terminated core filenames from QEMU
  * PR/359: Add support for http://ndjson.org/ 
  * PR/362: Fix wide printing 
  * PR/358: Fix width for -f -
- drop file-boo1201350.patch (upstream)

OBS-URL: https://build.opensuse.org/package/show/Base:System/file?expand=0&rev=254
This commit is contained in:
Dirk Mueller 2022-09-13 20:12:04 +00:00 committed by Git OBS Bridge
parent b9cdea4d60
commit d0cf1947a6
15 changed files with 116 additions and 263 deletions

View File

@ -1,6 +1,8 @@
--- file-5.39/src/file.c.orig 2020-06-17 16:13:36.625305367 +0200
+++ file-5.39/src/file.c 2020-06-17 16:15:12.429553163 +0200
@@ -254,6 +254,8 @@
Index: file-5.43/src/file.c
===================================================================
--- file-5.43.orig/src/file.c
+++ file-5.43/src/file.c
@@ -260,6 +260,8 @@ main(int argc, char *argv[])
break;
case 'e':
case OPT_EXCLUDE_QUIET:
@ -9,7 +11,7 @@
for (i = 0; i < __arraycount(nv); i++)
if (strcmp(nv[i].name, optarg) == 0)
break;
@@ -266,7 +268,7 @@
@@ -272,7 +274,7 @@ main(int argc, char *argv[])
break;
case 'f':
@ -18,7 +20,7 @@
usage();
if (magic == NULL)
if ((magic = load(magicfile, flags)) == NULL)
@@ -276,6 +278,8 @@
@@ -282,6 +284,8 @@ main(int argc, char *argv[])
++didsomefiles;
break;
case 'F':
@ -27,7 +29,7 @@
separator = optarg;
break;
case 'i':
@@ -288,6 +292,8 @@
@@ -294,6 +298,8 @@ main(int argc, char *argv[])
action = FILE_LIST;
break;
case 'm':

View File

@ -2,9 +2,11 @@
magic/Magdir/images | 2 ++
1 file changed, 2 insertions(+)
--- magic/Magdir/images
+++ magic/Magdir/images 2022-06-13 08:30:37.596139595 +0000
@@ -1951,6 +1951,8 @@
Index: magic/Magdir/images
===================================================================
--- magic/Magdir/images.orig
+++ magic/Magdir/images
@@ -1969,6 +1969,8 @@
# https://web.archive.org/web/20050317223257/www.cs.ubc.ca/spider/ladic/text/biorad.txt
# Samples: https://www.loci.wisc.edu/software/sample-data
14 uleshort <2

View File

@ -2,9 +2,11 @@
src/apprentice.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- src/apprentice.c
+++ src/apprentice.c 2021-10-19 08:52:01.991343421 +0000
@@ -2608,7 +2608,7 @@ check_format_type(const char *ptr, int t
Index: src/apprentice.c
===================================================================
--- src/apprentice.c.orig
+++ src/apprentice.c
@@ -2619,7 +2619,7 @@ check_format_type(const char *ptr, int t
}
} else
h = 0;

View File

@ -2,9 +2,11 @@
magic/Magdir/archive | 5 +++++
1 file changed, 5 insertions(+)
--- magic/Magdir/archive
+++ magic/Magdir/archive 2019-02-21 06:49:05.298138025 +0000
@@ -1399,6 +1399,11 @@
Index: magic/Magdir/archive
===================================================================
--- magic/Magdir/archive.orig
+++ magic/Magdir/archive
@@ -1421,6 +1421,11 @@
0 string PK\x07\x08PK\x03\x04 Zip multi-volume archive data, at least PKZIP v2.50 to extract
!:mime application/zip
!:ext zip/cbz

View File

@ -2,9 +2,11 @@
src/readelf.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- src/readelf.c
+++ src/readelf.c 2019-02-21 06:41:38.598573505 +0000
@@ -824,7 +824,7 @@ do_core_note(struct magic_set *ms, unsig
Index: src/readelf.c
===================================================================
--- src/readelf.c.orig
+++ src/readelf.c
@@ -825,7 +825,7 @@ do_core_note(struct magic_set *ms, unsig
default:
if (type == NT_PRPSINFO && *flags & FLAGS_IS_CORE) {
@ -13,7 +15,7 @@
unsigned char c;
/*
* Extract the program name. We assume
@@ -836,7 +836,9 @@ do_core_note(struct magic_set *ms, unsig
@@ -837,7 +837,9 @@ do_core_note(struct magic_set *ms, unsig
* If the characters aren't all printable,
* reject it.
*/

View File

@ -13,9 +13,10 @@ contained within the image.
magic/Magdir/filesystems | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/magic/Magdir/filesystems b/magic/Magdir/filesystems
--- a/magic/Magdir/filesystems
+++ b/magic/Magdir/filesystems
Index: file-5.43/magic/Magdir/filesystems
===================================================================
--- file-5.43.orig/magic/Magdir/filesystems
+++ file-5.43/magic/Magdir/filesystems
@@ -2302,20 +2302,29 @@
>>0x10060 string >\0 lockproto %s)

View File

@ -9,8 +9,10 @@
src/dcore.c | 207 +++++++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 313 insertions(+), 68 deletions(-)
--- magic/Magdir/elf
+++ magic/Magdir/elf 2022-06-13 08:44:29.248838085 +0000
Index: magic/Magdir/elf
===================================================================
--- magic/Magdir/elf.orig
+++ magic/Magdir/elf
@@ -152,7 +152,7 @@
>18 leshort 47 Renesas H8/300H,
>18 leshort 48 Renesas H8S,
@ -20,8 +22,10 @@
>18 leshort 51 Stanford MIPS-X,
>18 leshort 52 Motorola Coldfire,
>18 leshort 53 Motorola M68HC12,
--- magic/Magdir/linux
+++ magic/Magdir/linux 2022-06-13 08:44:29.248838085 +0000
Index: magic/Magdir/linux
===================================================================
--- magic/Magdir/linux.orig
+++ magic/Magdir/linux
@@ -140,27 +140,31 @@
# All known start with: b8 c0 07 8e d8 b8 00 90 8e c0 b9 00 01 29 f6 29
# Linux kernel boot images (i386 arch) (Wolfram Kleff)
@ -70,16 +74,20 @@
# This also matches new kernels, which were caught above by "HdrS".
0 belong 0xb8c0078e Linux kernel
>0x1e3 string Loading version 1.3.79 or older
--- magic/Magdir/msad
+++ magic/Magdir/msad 2022-06-13 08:44:29.248838085 +0000
Index: magic/Magdir/msad
===================================================================
--- /dev/null
+++ magic/Magdir/msad
@@ -0,0 +1,5 @@
+#------------------------------------------------------------------------------
+# msad: file(1) magic for msad
+# Microsoft visual C
+# This must precede the heuristic for raw G3 data
+4 string Standard\ Jet\ DB Microsoft Access Database
--- magic/Magdir/msdos
+++ magic/Magdir/msdos 2022-06-13 08:44:29.248838085 +0000
Index: magic/Magdir/msdos
===================================================================
--- magic/Magdir/msdos.orig
+++ magic/Magdir/msdos
@@ -145,9 +145,9 @@
>>(0x3c.l+22) leshort&0x0200 >0 (stripped to external PDB)
>>(0x3c.l+22) leshort&0x1000 >0 system file
@ -92,17 +100,19 @@
# hooray, there's a DOS extender using the PE format, with a valid PE
# executable inside (which just prints a message and exits if run in win)
@@ -635,7 +635,7 @@
# negative offset, must not lead into PSP
>1 short <-259
@@ -750,7 +750,7 @@
>1 leshort <-259
# that offset must be accessible
# add 10000h to jump at end of 64 KiB segment, add 1 for jump instruction and 2 for 16-bit offset
->>(1,s+65539) byte x
+>>(1.s+65539) byte x
# after jump next instruction for DEBUGGING!
#>>>&-1 ubelong x \b, NEXT instruction %#8.8x
>>>0 use msdos-com
# updated by Joerg Jenderek at Oct 2008,2015
--- magic/Makefile.am
+++ magic/Makefile.am 2022-06-13 08:44:29.248838085 +0000
Index: magic/Makefile.am
===================================================================
--- magic/Makefile.am.orig
+++ magic/Makefile.am
@@ -5,7 +5,7 @@ MAGIC_FRAGMENT_BASE = Magdir
MAGIC_DIR = $(top_srcdir)/magic
MAGIC_FRAGMENT_DIR = $(MAGIC_DIR)/$(MAGIC_FRAGMENT_BASE)
@ -120,7 +130,7 @@
$(MAGIC_FRAGMENT_DIR)/application \
$(MAGIC_FRAGMENT_DIR)/applix \
$(MAGIC_FRAGMENT_DIR)/apt \
@@ -105,7 +104,6 @@ $(MAGIC_FRAGMENT_DIR)/erlang \
@@ -106,7 +105,6 @@ $(MAGIC_FRAGMENT_DIR)/erlang \
$(MAGIC_FRAGMENT_DIR)/espressif \
$(MAGIC_FRAGMENT_DIR)/esri \
$(MAGIC_FRAGMENT_DIR)/fcs \
@ -128,7 +138,7 @@
$(MAGIC_FRAGMENT_DIR)/finger \
$(MAGIC_FRAGMENT_DIR)/flash \
$(MAGIC_FRAGMENT_DIR)/flif \
@@ -150,6 +148,8 @@ $(MAGIC_FRAGMENT_DIR)/isz \
@@ -152,6 +150,8 @@ $(MAGIC_FRAGMENT_DIR)/isz \
$(MAGIC_FRAGMENT_DIR)/java \
$(MAGIC_FRAGMENT_DIR)/javascript \
$(MAGIC_FRAGMENT_DIR)/jpeg \
@ -137,7 +147,7 @@
$(MAGIC_FRAGMENT_DIR)/karma \
$(MAGIC_FRAGMENT_DIR)/kde \
$(MAGIC_FRAGMENT_DIR)/keepass \
@@ -160,7 +160,6 @@ $(MAGIC_FRAGMENT_DIR)/lammps \
@@ -162,7 +162,6 @@ $(MAGIC_FRAGMENT_DIR)/lammps \
$(MAGIC_FRAGMENT_DIR)/lecter \
$(MAGIC_FRAGMENT_DIR)/lex \
$(MAGIC_FRAGMENT_DIR)/lif \
@ -145,7 +155,7 @@
$(MAGIC_FRAGMENT_DIR)/lisp \
$(MAGIC_FRAGMENT_DIR)/llvm \
$(MAGIC_FRAGMENT_DIR)/locoscript \
@@ -168,7 +167,6 @@ $(MAGIC_FRAGMENT_DIR)/lua \
@@ -170,7 +169,6 @@ $(MAGIC_FRAGMENT_DIR)/lua \
$(MAGIC_FRAGMENT_DIR)/luks \
$(MAGIC_FRAGMENT_DIR)/m4 \
$(MAGIC_FRAGMENT_DIR)/mach \
@ -153,7 +163,7 @@
$(MAGIC_FRAGMENT_DIR)/macos \
$(MAGIC_FRAGMENT_DIR)/magic \
$(MAGIC_FRAGMENT_DIR)/mail.news \
@@ -192,11 +190,11 @@ $(MAGIC_FRAGMENT_DIR)/misctools \
@@ -194,11 +192,11 @@ $(MAGIC_FRAGMENT_DIR)/misctools \
$(MAGIC_FRAGMENT_DIR)/mkid \
$(MAGIC_FRAGMENT_DIR)/mlssa \
$(MAGIC_FRAGMENT_DIR)/mmdf \
@ -166,16 +176,16 @@
$(MAGIC_FRAGMENT_DIR)/msooxml \
$(MAGIC_FRAGMENT_DIR)/msvc \
$(MAGIC_FRAGMENT_DIR)/msx \
@@ -258,6 +256,8 @@ $(MAGIC_FRAGMENT_DIR)/python \
$(MAGIC_FRAGMENT_DIR)/qt \
@@ -261,6 +259,8 @@ $(MAGIC_FRAGMENT_DIR)/qt \
$(MAGIC_FRAGMENT_DIR)/revision \
$(MAGIC_FRAGMENT_DIR)/ringdove \
$(MAGIC_FRAGMENT_DIR)/riff \
+$(MAGIC_FRAGMENT_DIR)/apple \
+$(MAGIC_FRAGMENT_DIR)/macintosh \
$(MAGIC_FRAGMENT_DIR)/rpi \
$(MAGIC_FRAGMENT_DIR)/rpm \
$(MAGIC_FRAGMENT_DIR)/rpmsg \
@@ -347,9 +347,21 @@ EXTRA_DIST = \
@@ -351,9 +351,21 @@ EXTRA_DIST = \
$(MAGIC_DIR)/scripts/create_filemagic_flac \
$(MAGIC_FRAGMENTS)
@ -199,7 +209,7 @@
# FIXME: Build file natively as well so that it can be used to compile
# the target's magic file; for now we bail if the local version does not match
@@ -361,19 +373,22 @@ FILE_COMPILE = $(top_builddir)/src/file$
@@ -365,19 +377,22 @@ FILE_COMPILE = $(top_builddir)/src/file$
FILE_COMPILE_DEP = $(FILE_COMPILE)
endif
@ -238,9 +248,11 @@
+# fi)
+# $(FILE_COMPILE) -C -m magic
+# @rm -fr magic
--- magic/Makefile.in
+++ magic/Makefile.in 2022-06-13 08:44:29.248838085 +0000
@@ -280,7 +280,7 @@ top_srcdir = @top_srcdir@
Index: magic/Makefile.in
===================================================================
--- magic/Makefile.in.orig
+++ magic/Makefile.in
@@ -283,7 +283,7 @@ top_srcdir = @top_srcdir@
MAGIC_FRAGMENT_BASE = Magdir
MAGIC_DIR = $(top_srcdir)/magic
MAGIC_FRAGMENT_DIR = $(MAGIC_DIR)/$(MAGIC_FRAGMENT_BASE)
@ -249,7 +261,7 @@
MAGIC_FRAGMENTS = \
$(MAGIC_DIR)/Header \
$(MAGIC_DIR)/Localstuff \
@@ -298,7 +298,6 @@ $(MAGIC_FRAGMENT_DIR)/animation \
@@ -301,7 +301,6 @@ $(MAGIC_FRAGMENT_DIR)/animation \
$(MAGIC_FRAGMENT_DIR)/aout \
$(MAGIC_FRAGMENT_DIR)/apache \
$(MAGIC_FRAGMENT_DIR)/apl \
@ -257,7 +269,7 @@
$(MAGIC_FRAGMENT_DIR)/application \
$(MAGIC_FRAGMENT_DIR)/applix \
$(MAGIC_FRAGMENT_DIR)/apt \
@@ -379,7 +378,6 @@ $(MAGIC_FRAGMENT_DIR)/erlang \
@@ -383,7 +382,6 @@ $(MAGIC_FRAGMENT_DIR)/erlang \
$(MAGIC_FRAGMENT_DIR)/espressif \
$(MAGIC_FRAGMENT_DIR)/esri \
$(MAGIC_FRAGMENT_DIR)/fcs \
@ -265,7 +277,7 @@
$(MAGIC_FRAGMENT_DIR)/finger \
$(MAGIC_FRAGMENT_DIR)/flash \
$(MAGIC_FRAGMENT_DIR)/flif \
@@ -424,6 +422,8 @@ $(MAGIC_FRAGMENT_DIR)/isz \
@@ -429,6 +427,8 @@ $(MAGIC_FRAGMENT_DIR)/isz \
$(MAGIC_FRAGMENT_DIR)/java \
$(MAGIC_FRAGMENT_DIR)/javascript \
$(MAGIC_FRAGMENT_DIR)/jpeg \
@ -274,7 +286,7 @@
$(MAGIC_FRAGMENT_DIR)/karma \
$(MAGIC_FRAGMENT_DIR)/kde \
$(MAGIC_FRAGMENT_DIR)/keepass \
@@ -434,7 +434,6 @@ $(MAGIC_FRAGMENT_DIR)/lammps \
@@ -439,7 +439,6 @@ $(MAGIC_FRAGMENT_DIR)/lammps \
$(MAGIC_FRAGMENT_DIR)/lecter \
$(MAGIC_FRAGMENT_DIR)/lex \
$(MAGIC_FRAGMENT_DIR)/lif \
@ -282,7 +294,7 @@
$(MAGIC_FRAGMENT_DIR)/lisp \
$(MAGIC_FRAGMENT_DIR)/llvm \
$(MAGIC_FRAGMENT_DIR)/locoscript \
@@ -442,7 +441,6 @@ $(MAGIC_FRAGMENT_DIR)/lua \
@@ -447,7 +446,6 @@ $(MAGIC_FRAGMENT_DIR)/lua \
$(MAGIC_FRAGMENT_DIR)/luks \
$(MAGIC_FRAGMENT_DIR)/m4 \
$(MAGIC_FRAGMENT_DIR)/mach \
@ -290,7 +302,7 @@
$(MAGIC_FRAGMENT_DIR)/macos \
$(MAGIC_FRAGMENT_DIR)/magic \
$(MAGIC_FRAGMENT_DIR)/mail.news \
@@ -466,11 +464,11 @@ $(MAGIC_FRAGMENT_DIR)/misctools \
@@ -471,11 +469,11 @@ $(MAGIC_FRAGMENT_DIR)/misctools \
$(MAGIC_FRAGMENT_DIR)/mkid \
$(MAGIC_FRAGMENT_DIR)/mlssa \
$(MAGIC_FRAGMENT_DIR)/mmdf \
@ -303,16 +315,16 @@
$(MAGIC_FRAGMENT_DIR)/msooxml \
$(MAGIC_FRAGMENT_DIR)/msvc \
$(MAGIC_FRAGMENT_DIR)/msx \
@@ -532,6 +530,8 @@ $(MAGIC_FRAGMENT_DIR)/python \
$(MAGIC_FRAGMENT_DIR)/qt \
@@ -538,6 +536,8 @@ $(MAGIC_FRAGMENT_DIR)/qt \
$(MAGIC_FRAGMENT_DIR)/revision \
$(MAGIC_FRAGMENT_DIR)/ringdove \
$(MAGIC_FRAGMENT_DIR)/riff \
+$(MAGIC_FRAGMENT_DIR)/apple \
+$(MAGIC_FRAGMENT_DIR)/macintosh \
$(MAGIC_FRAGMENT_DIR)/rpi \
$(MAGIC_FRAGMENT_DIR)/rpm \
$(MAGIC_FRAGMENT_DIR)/rpmsg \
@@ -621,10 +621,22 @@ EXTRA_DIST = \
@@ -628,10 +628,22 @@ EXTRA_DIST = \
$(MAGIC_DIR)/scripts/create_filemagic_flac \
$(MAGIC_FRAGMENTS)
@ -336,7 +348,7 @@
# FIXME: Build file natively as well so that it can be used to compile
# the target's magic file; for now we bail if the local version does not match
@IS_CROSS_COMPILE_TRUE@FILE_COMPILE = file${EXEEXT}
@@ -849,23 +861,25 @@ uninstall-am: uninstall-pkgdataDATA
@@ -855,23 +867,25 @@ uninstall-am: uninstall-pkgdataDATA
.PRECIOUS: Makefile
@ -378,16 +390,20 @@
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
--- src/Makefile.am
+++ src/Makefile.am 2022-06-13 08:44:29.248838085 +0000
Index: src/Makefile.am
===================================================================
--- src/Makefile.am.orig
+++ src/Makefile.am
@@ -1,4 +1,4 @@
-MAGIC = $(pkgdatadir)/magic
+MAGIC = $(sysconfdir)/magic:$(pkgdatadir)/magic
lib_LTLIBRARIES = libmagic.la
nodist_include_HEADERS = magic.h
--- src/dcore.c
+++ src/dcore.c 2022-06-13 08:44:29.248838085 +0000
Index: src/dcore.c
===================================================================
--- /dev/null
+++ src/dcore.c
@@ -0,0 +1,207 @@
+/*
+ * Show goo about ELF core files

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c076fb4d029c74073f15c43361ef572cfb868407d347190ba834af3b1639b0e4
size 1105846

View File

@ -1,6 +0,0 @@
-----BEGIN PGP SIGNATURE-----
iF0EABECAB0WIQS+BJlbqPkO0MDBdsRxESqxbLM7OgUCYqNK1QAKCRBxESqxbLM7
Or2rAKDIx6yR4k5adLOh6+dwe3gHGeq7SwCffNuFkJgje9xr31P0KaZEPBdd91Q=
=cCEN
-----END PGP SIGNATURE-----

3
file-5.43.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8c8015e91ae0e8d0321d94c78239892ef9dbc70c4ade0008c0e95894abfb1991
size 1162786

6
file-5.43.tar.gz.asc Normal file
View File

@ -0,0 +1,6 @@
-----BEGIN PGP SIGNATURE-----
iF0EABECAB0WIQS+BJlbqPkO0MDBdsRxESqxbLM7OgUCYyDSYwAKCRBxESqxbLM7
Oq5DAJ4i24Hoo/BQ/twN6reZthvb2VyUsQCfb4+yj6JJW5C0fA++P/KYbrJChug=
=3+aN
-----END PGP SIGNATURE-----

View File

@ -1,186 +0,0 @@
From c80065fe6900be5e794941e29b32440e9969b1c3 Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Mon, 4 Jul 2022 19:44:35 +0000
Subject: [PATCH 1/5] PR/362: ro-ee: fix wide char printing
---
src/file.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++-------------
src/file.h | 4 +-
src/funcs.c | 4 +-
3 files changed, 81 insertions(+), 24 deletions(-)
--- src/file.c
+++ src/file.c 2022-07-21 13:56:33.280169243 +0000
@@ -60,6 +60,12 @@ FILE_RCSID("@(#)$File: file.c,v 1.195 20
#ifdef HAVE_WCTYPE_H
#include <wctype.h>
#endif
+#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH) && \
+ defined(HAVE_WCTYPE_H)
+#define FILE_WIDE_SUPPORT
+#else
+#include <ctype.h>
+#endif
#if defined(HAVE_GETOPT_H) && defined(HAVE_STRUCT_OPTION)
# include <getopt.h>
@@ -544,6 +550,58 @@ unwrap(struct magic_set *ms, const char
return e;
}
+private void
+file_octal(unsigned char c)
+{
+ putc('\\', stdout);
+ putc(((c >> 6) & 7) + '0', stdout);
+ putc(((c >> 3) & 7) + '0', stdout);
+ putc(((c >> 0) & 7) + '0', stdout);
+}
+
+private void
+fname_print(const char *inname)
+{
+ size_t n = strlen(inname);
+#ifdef FILE_WIDE_SUPPORT
+ mbstate_t state;
+ wchar_t nextchar;
+ size_t bytesconsumed;
+
+
+ (void)memset(&state, 0, sizeof(state));
+ while (n > 0) {
+ bytesconsumed = mbrtowc(&nextchar, inname, n, &state);
+ if (bytesconsumed == CAST(size_t, -1) ||
+ bytesconsumed == CAST(size_t, -2)) {
+ nextchar = *inname++;
+ n--;
+ (void)memset(&state, 0, sizeof(state));
+ file_octal(CAST(unsigned char, nextchar));
+ continue;
+ }
+ inname += bytesconsumed;
+ n -= bytesconsumed;
+ if (iswprint(nextchar)) {
+ printf("%lc", nextchar);
+ continue;
+ }
+ /* XXX: What if it is > 255? */
+ file_octal(CAST(unsigned char, nextchar));
+ }
+#else
+ size_t i;
+ for (i = 0; i < n; i++) {
+ unsigned char c = CAST(unsigned char, inname[i]);
+ if (isprint(c)) {
+ putc(c);
+ continue;
+ }
+ file_octal(c);
+ }
+#endif
+}
+
/*
* Called for each input file on the command line (or in a list of files)
*/
@@ -553,15 +611,13 @@ process(struct magic_set *ms, const char
const char *type, c = nulsep > 1 ? '\0' : '\n';
int std_in = strcmp(inname, "-") == 0;
int haderror = 0;
- size_t plen = 4 * wid + 1;
- char *pbuf, *pname;
-
- if ((pbuf = CAST(char *, malloc(plen))) == NULL)
- file_err(EXIT_FAILURE, "Can't allocate %zu bytes", plen);
if (wid > 0 && !bflag) {
- pname = file_printable(ms, pbuf, plen, inname, wid);
- (void)printf("%s", std_in ? "/dev/stdin" : pname);
+ const char *pname = std_in ? "/dev/stdin" : inname;
+ if ((ms->flags & MAGIC_RAW) == 0)
+ fname_print(pname);
+ else
+ (void)printf("%s", pname);
if (nulsep)
(void)putc('\0', stdout);
if (nulsep < 2) {
@@ -580,7 +636,6 @@ process(struct magic_set *ms, const char
}
if (nobuffer)
haderror |= fflush(stdout) != 0;
- free(pbuf);
return haderror || type == NULL;
}
@@ -588,35 +643,37 @@ protected size_t
file_mbswidth(struct magic_set *ms, const char *s)
{
size_t width = 0;
-#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH) && \
- defined(HAVE_WCTYPE_H)
- size_t bytesconsumed, old_n, n;
+#ifdef FILE_WIDE_SUPPORT
+ size_t bytesconsumed, n;
mbstate_t state;
wchar_t nextchar;
- (void)memset(&state, 0, sizeof(mbstate_t));
- old_n = n = strlen(s);
+
+ (void)memset(&state, 0, sizeof(state));
+ n = strlen(s);
while (n > 0) {
bytesconsumed = mbrtowc(&nextchar, s, n, &state);
if (bytesconsumed == CAST(size_t, -1) ||
bytesconsumed == CAST(size_t, -2)) {
- /* Something went wrong, return something reasonable */
- return old_n;
+ nextchar = *s;
+ bytesconsumed = 1;
+ (void)memset(&state, 0, sizeof(state));
+ width += 4;
+ } else {
+ int w = wcwidth(nextchar);
+ width += ((ms->flags & MAGIC_RAW) != 0
+ || iswprint(nextchar)) ? (w > 0 ? w : 1) : 4;
}
- width += ((ms->flags & MAGIC_RAW) != 0
- || iswprint(nextchar)) ? wcwidth(nextchar) : 4;
s += bytesconsumed, n -= bytesconsumed;
}
- return width;
#else
while (*s) {
width += (ms->flags & MAGIC_RAW) != 0
|| isprint(CAST(unsigned char, *s)) ? 1 : 4;
}
-
- return strlen(s);
#endif
+ return width;
}
private void
--- src/file.h
+++ src/file.h 2022-07-21 13:56:33.280169243 +0000
@@ -575,7 +575,7 @@ protected size_t file_pstring_length_siz
const struct magic *);
protected size_t file_pstring_get_length(struct magic_set *,
const struct magic *, const char *);
-public char * file_printable(struct magic_set *, char *, size_t,
+protected char * file_printable(struct magic_set *, char *, size_t,
const char *, size_t);
#ifdef __EMX__
protected int file_os2_apptype(struct magic_set *, const char *, const void *,
--- src/funcs.c
+++ src/funcs.c 2022-07-21 13:56:33.280169243 +0000
@@ -763,7 +763,7 @@ file_pop_buffer(struct magic_set *ms, fi
/*
* convert string to ascii printable format.
*/
-public char *
+protected char *
file_printable(struct magic_set *ms, char *buf, size_t bufsiz,
const char *str, size_t slen)
{

View File

@ -1,3 +1,17 @@
-------------------------------------------------------------------
Tue Sep 13 20:09:35 UTC 2022 - Dirk Müller <dmueller@suse.com>
- update to 5.43:
* Add octal indirect magic
* avoid infinite loop in non-wide code
* Obey MAGIC_CONTINUE with multiple magic files
* Fix bug with large flist
* PR/364: Detect non-nul-terminated core filenames from QEMU
* PR/359: Add support for http://ndjson.org/
* PR/362: Fix wide printing
* PR/358: Fix width for -f -
- drop file-boo1201350.patch (upstream)
-------------------------------------------------------------------
Thu Aug 25 19:31:39 UTC 2022 - Callum Farmer <gmbr3@opensuse.org>
@ -62,6 +76,7 @@ Wed Mar 23 09:02:37 UTC 2022 - Dirk Müller <dmueller@suse.com>
- add file-5.41-cache-regexps-locale-restore.patch to restore
previous locale handling behavior
-------------------------------------------------------------------
Sat Mar 19 18:00:32 UTC 2022 - Dirk Müller <dmueller@suse.com>

View File

@ -33,7 +33,7 @@ Obsoletes: file-64bit
%endif
#
# Set Version also in python-magic.spec
Version: 5.42
Version: 5.43
Release: 0
Summary: A Tool to Determine File Types
License: BSD-2-Clause
@ -62,8 +62,6 @@ Patch31: file-5.19-biorad.dif
Patch32: file-5.19-clicfs.dif
Patch37: file-secure_getenv.patch
Patch39: file-5.28-btrfs-image.dif
# Upstream commits as patch
Patch42: file-boo1201350.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%global _sysconfdir /etc
%global magicdir %{_datadir}/file
@ -108,7 +106,6 @@ to develop applications that require the magic "file" interface.
%prep
%setup -q -n file-%{version}
%patch42 -p0
%patch1 -p0 -b .misc
%patch4 -p0 -b .conf
%patch5 -p0 -b .tex

View File

@ -21,7 +21,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%global _miscdir %{_datadir}/misc
Name: python-magic
Version: 5.42
Version: 5.43
Release: 0
Summary: Python module to use libmagic
License: BSD-3-Clause AND BSD-4-Clause