From 8281160d1586ddae424604feb46a84c4d414fc1b Mon Sep 17 00:00:00 2001 From: Adam Thompson-Sharpe Date: Thu, 30 Apr 2026 02:31:31 -0400 Subject: [PATCH] file: 5.45 -> 5.47 The bugs that prevented upgrading to v5.46 have been fixed in the latest version. --- ...-Don-t-flush-when-trying-to-set-nega.patch | 57 +++++++++++++++++++ pkgs/tools/misc/file/32-bit-time_t.patch | 38 ------------- pkgs/tools/misc/file/default.nix | 21 +++---- 3 files changed, 65 insertions(+), 51 deletions(-) create mode 100644 pkgs/tools/misc/file/0001-PR-745-streamout-Don-t-flush-when-trying-to-set-nega.patch delete mode 100644 pkgs/tools/misc/file/32-bit-time_t.patch diff --git a/pkgs/tools/misc/file/0001-PR-745-streamout-Don-t-flush-when-trying-to-set-nega.patch b/pkgs/tools/misc/file/0001-PR-745-streamout-Don-t-flush-when-trying-to-set-nega.patch new file mode 100644 index 000000000000..77ad10f252c7 --- /dev/null +++ b/pkgs/tools/misc/file/0001-PR-745-streamout-Don-t-flush-when-trying-to-set-nega.patch @@ -0,0 +1,57 @@ +From 12b76648185104ce9118d8b5fa57aa34a77ad084 Mon Sep 17 00:00:00 2001 +From: Christos Zoulas +Date: Wed, 15 Apr 2026 20:00:20 +0000 +Subject: [PATCH] PR/745: streamout: Don't flush when trying to set negative + offsets on pipes, just continue, fixes 'cat file.zip | file -' + +--- + ChangeLog | 2 ++ + src/softmagic.c | 22 ++++++++++++++++------ + 2 files changed, 18 insertions(+), 6 deletions(-) + +diff --git a/src/softmagic.c b/src/softmagic.c +index 7cf7c798..a5e758eb 100644 +--- a/src/softmagic.c ++++ b/src/softmagic.c +@@ -245,14 +245,19 @@ match(struct magic_set *ms, struct magic *magic, file_regex_t **magic_rxcomp, + flush: + /* Skip sub-tests */ + while (magindex < nmagic - 1 && +- magic[magindex + 1].cont_level != 0) ++ magic[magindex + 1].cont_level != 0) { + magindex++; ++ } + cont_level = 0; + continue; /* Skip to next top-level test*/ + } + +- if (msetoffset(ms, m, &bb, b, offset, cont_level) == -1) +- goto flush; ++ if (msetoffset(ms, m, &bb, b, offset, cont_level) == -1) { ++ if (b->elen == FILE_BADSIZE) ++ continue; ++ else ++ goto flush; ++ } + ms->line = m->lineno; + + /* if main entry matches, print it... */ +@@ -347,8 +352,13 @@ flush: + */ + cont_level = m->cont_level; + } +- if (msetoffset(ms, m, &bb, b, offset, cont_level) == -1) +- goto flush; ++ if (msetoffset(ms, m, &bb, b, offset, cont_level) ++ == -1) { ++ if (b->elen == FILE_BADSIZE) ++ continue; ++ else ++ goto flush; ++ } + if (m->flag & OFFADD) { + if (cont_level == 0) { + if ((ms->flags & MAGIC_DEBUG) != 0) +-- +2.53.0 + diff --git a/pkgs/tools/misc/file/32-bit-time_t.patch b/pkgs/tools/misc/file/32-bit-time_t.patch deleted file mode 100644 index 19c595215d65..000000000000 --- a/pkgs/tools/misc/file/32-bit-time_t.patch +++ /dev/null @@ -1,38 +0,0 @@ -https://github.com/file/file/commit/218fdf813fd5ccecbb8887a1b62509cd1c6dd3a1.patch - -From 218fdf813fd5ccecbb8887a1b62509cd1c6dd3a1 Mon Sep 17 00:00:00 2001 -From: Christos Zoulas -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 */ diff --git a/pkgs/tools/misc/file/default.nix b/pkgs/tools/misc/file/default.nix index 34f58c1f92a8..dd856e5aef20 100644 --- a/pkgs/tools/misc/file/default.nix +++ b/pkgs/tools/misc/file/default.nix @@ -16,14 +16,14 @@ stdenv.mkDerivation (finalAttrs: { pname = "file"; - version = "5.45"; + version = "5.47"; src = fetchurl { urls = [ "https://astron.com/pub/file/file-${finalAttrs.version}.tar.gz" "https://distfiles.macports.org/file/file-${finalAttrs.version}.tar.gz" ]; - hash = "sha256-/Jf1ECm7DiyfTjv/79r2ePDgOe6HK53lwAKm0Jx4TYI="; + hash = "sha256-RWcv7BZctMwTWKLXa11X0ih23Ll6sWlCesOFy+HVWXo="; }; outputs = [ @@ -33,17 +33,12 @@ stdenv.mkDerivation (finalAttrs: { ]; patches = [ - # Upstream patch to fix 32-bit tests. - # - # It is included in 5.46+, but we are not updating to it or a later version until: - # - # https://bugs.astron.com/view.php?id=622 - # https://bugs.astron.com/view.php?id=638 - # - # are resolved. See also description of the 1st bug here: - # - # https://github.com/NixOS/nixpkgs/pull/402318#issuecomment-2881163359 - ./32-bit-time_t.patch + # Fixes `cat archive.zip | file -` just showing a generic "data" type. See: + # - https://bugs.astron.com/view.php?id=764 + # - https://github.com/file/file/commit/12b76648185104ce9118d8b5fa57aa34a77ad084 + # Vendored patch because using fetchpatch is impossible for a package in + # this part of the bootstrap chain. + ./0001-PR-745-streamout-Don-t-flush-when-trying-to-set-nega.patch ]; strictDeps = true;