reapply: update to new version 5.42

and fix (#2095871)
This commit is contained in:
Vincent Mihalkovic 2022-07-21 15:55:20 +02:00
parent 874c9f675d
commit def8ebfc2a
8 changed files with 93 additions and 155 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
/file-5.*.tar.gz
/file-5.*.tar.gz.asc
/christoskey.asc
/file-5.41.tar.gz.asc

View File

@ -1,41 +0,0 @@
From f687fa2b92cd923173126614516c1d07894affb3 Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Wed, 8 Dec 2021 13:42:00 +0000
Subject: [PATCH] Don't use search; interpreters need to be always in the first
line. Fixes strength issue (general #! in commands ranked higher).
---
magic/Magdir/javascript | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/magic/Magdir/javascript b/magic/Magdir/javascript
index 7fa9d9d40..1e29c5e8e 100644
--- a/magic/Magdir/javascript
+++ b/magic/Magdir/javascript
@@ -1,19 +1,19 @@
#------------------------------------------------------------------------------
-# $File: javascript,v 1.2 2019/08/05 10:34:26 christos Exp $
+# $File: javascript,v 1.3 2021/12/08 13:42:00 christos Exp $
# javascript: magic for javascript and node.js scripts.
#
-0 search/1/w #!/bin/node Node.js script text executable
+0 string/w #!/bin/node Node.js script text executable
!:mime application/javascript
-0 search/1/w #!/usr/bin/node Node.js script text executable
+0 string/w #!/usr/bin/node Node.js script text executable
!:mime application/javascript
-0 search/1/w #!/bin/nodejs Node.js script text executable
+0 string/w #!/bin/nodejs Node.js script text executable
!:mime application/javascript
-0 search/1/w #!/usr/bin/nodejs Node.js script text executable
+0 string/w #!/usr/bin/nodejs Node.js script text executable
!:mime application/javascript
-0 search/1 #!/usr/bin/env\ node Node.js script text executable
+0 string #!/usr/bin/env\ node Node.js script text executable
!:mime application/javascript
-0 search/1 #!/usr/bin/env\ nodejs Node.js script text executable
+0 string #!/usr/bin/env\ nodejs Node.js script text executable
!:mime application/javascript
# Hermes by Facebook https://hermesengine.dev/
# https://github.com/facebook/hermes/blob/master/include/hermes/\

View File

@ -1,31 +0,0 @@
From c49e7805fd8aa48b8d2afad98d2115560ffaaf21 Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Thu, 9 Dec 2021 18:38:43 +0000
Subject: [PATCH] JSON is text data, requested by Vincent Mihalkovic.
---
src/is_json.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/is_json.c b/src/is_json.c
index 0b12438ff..4ff49b3bb 100644
--- a/src/is_json.c
+++ b/src/is_json.c
@@ -32,7 +32,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: is_json.c,v 1.15 2020/06/07 19:05:47 christos Exp $")
+FILE_RCSID("@(#)$File: is_json.c,v 1.16 2021/12/09 18:38:43 christos Exp $")
#endif
#include <string.h>
@@ -414,7 +414,7 @@ file_is_json(struct magic_set *ms, const struct buffer *b)
return -1;
return 1;
}
- if (file_printf(ms, "JSON data") == -1)
+ if (file_printf(ms, "JSON text data") == -1)
return -1;
#if JSON_COUNT
#define P(n) st[n], st[n] > 1 ? "s" : ""

View File

@ -1,35 +0,0 @@
From e83f5046ef2d8967f14db5063a09c91f54f68063 Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Sun, 12 Dec 2021 16:23:06 +0000
Subject: [PATCH] remove trailing newline
---
tests/json1.result | 2 +-
tests/json2.result | 2 +-
tests/json3.result | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/json1.result b/tests/json1.result
index 7d635242f..550d7ac2f 100644
--- a/tests/json1.result
+++ b/tests/json1.result
@@ -1 +1 @@
-JSON text data
+JSON text data
\ No newline at end of file
diff --git a/tests/json2.result b/tests/json2.result
index 7d635242f..550d7ac2f 100644
--- a/tests/json2.result
+++ b/tests/json2.result
@@ -1 +1 @@
-JSON text data
+JSON text data
\ No newline at end of file
diff --git a/tests/json3.result b/tests/json3.result
index 7d635242f..550d7ac2f 100644
--- a/tests/json3.result
+++ b/tests/json3.result
@@ -1 +1 @@
-JSON text data
+JSON text data
\ No newline at end of file

View File

@ -1,35 +0,0 @@
From 3012be8ca1cdee72471118eea0192e1e32cab862 Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Fri, 10 Dec 2021 18:36:41 +0000
Subject: [PATCH] Adjust tests to match what JSON prints now (Avinash Sonawane)
---
tests/json1.result | 2 +-
tests/json2.result | 2 +-
tests/json3.result | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/json1.result b/tests/json1.result
index 01442dc9c..7d635242f 100644
--- a/tests/json1.result
+++ b/tests/json1.result
@@ -1 +1 @@
-JSON data
\ No newline at end of file
+JSON text data
diff --git a/tests/json2.result b/tests/json2.result
index 01442dc9c..7d635242f 100644
--- a/tests/json2.result
+++ b/tests/json2.result
@@ -1 +1 @@
-JSON data
\ No newline at end of file
+JSON text data
diff --git a/tests/json3.result b/tests/json3.result
index 01442dc9c..7d635242f 100644
--- a/tests/json3.result
+++ b/tests/json3.result
@@ -1 +1 @@
-JSON data
\ No newline at end of file
+JSON text data

View File

@ -0,0 +1,83 @@
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;
}

View File

@ -14,8 +14,8 @@
Summary: Utility for determining file types
Name: file
Version: 5.41
Release: 7%{?dist}
Version: 5.42
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,14 +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/f687fa2b92cd9231
Patch3: file-5.41-javascript-magic.patch
# Upstream commit: https://github.com/file/file/commit/c49e7805fd8aa48b
Patch4: file-5.41-json-magic.patch
# Upstream commit: https://github.com/file/file/commit/3012be8ca1cdee72
Patch5: file-5.41-json-tests.patch
# Upstream commit: https://github.com/file/file/commit/e83f5046ef2d8967
Patch6: file-5.41-json-tests-fix.patch
# Upstream commit: https://github.com/file/file/commit/19bf47777d0002ee884467e45e6ace702e40a4c1
Patch3: file-5.42-fix-stdin-input.patch
URL: https://www.darwinsys.com/file/
Requires: file-libs%{?_isa} = %{version}-%{release}
@ -222,6 +216,9 @@ make -C tests check
%endif
%changelog
* Thu Jul 21 2022 Vincent Mihalkovic <vmihalko@redhat.com> - 5.42-1
- update to new version 5.42
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 5.41-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

View File

@ -1,3 +1,3 @@
SHA512 (file-5.42.tar.gz) = 33c3c339a561c6cf787cc06a16444a971c62068b01827612c948207a9714107b617bed8148cd67e6280cb1c62ad4dfb1205fb8486ea9c042ce7e19b067d3bb05
SHA512 (file-5.42.tar.gz.asc) = a7105c48f6c671638f5fb7f18f9b193d108456655b4c734208e00aca36fab54dd330ec2fdc3ff29fb78adbc16874af4fb0916c560e50228f82003a8cd258491a
SHA512 (christoskey.asc) = 952323eb3c0cd3ae1b6c059e301b176fd60b61c76789b96c800a995253bd8dd88182617a2358fbe09b9571cd642fd4098dd0d91152a6347669324d79b12f94ee
SHA512 (file-5.41.tar.gz.asc) = fc342ed92efde3f0400f61acd35d8f2d793788f3a2b8a53fbe9255dc04a036fa16b33294c184630b62471d825d5304a5c6580fcde654eea01b02e57dfbd50632
SHA512 (file-5.41.tar.gz) = bbf2d8e39450b31d0ba8d76d202790fea953775657f942f06e6dc9091798d4a395f7205e542388e4a25b6a4506d07f36c5c4da37cfce0734133e9203a3b00654