From ad9e2b1b7043010b95d764f7237d058a885b0ca7 Mon Sep 17 00:00:00 2001 From: Duncaen Date: Sat, 3 Sep 2022 15:23:59 +0200 Subject: [PATCH] file: update to 5.42, fix --files-from. --- .../file/patches/fix-files-from-flag.patch | 108 ++++++++++++++++++ srcpkgs/file/template | 5 +- 2 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 srcpkgs/file/patches/fix-files-from-flag.patch diff --git a/srcpkgs/file/patches/fix-files-from-flag.patch b/srcpkgs/file/patches/fix-files-from-flag.patch new file mode 100644 index 00000000000..574f019672c --- /dev/null +++ b/srcpkgs/file/patches/fix-files-from-flag.patch @@ -0,0 +1,108 @@ +From 19bf47777d0002ee884467e45e6ace702e40a4c1 Mon Sep 17 00:00:00 2001 +From: Christos Zoulas +Date: Mon, 4 Jul 2022 17:00:51 +0000 +Subject: [PATCH] PR/358: Fix width for -f - (jpalus) + +--- + ChangeLog | 3 ++- + src/file.c | 46 +++++++++++++++++++++++++++++----------------- + 2 files changed, 31 insertions(+), 18 deletions(-) + +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; + } + +From be1ac8c0aa6d21921012f62582f51a9e546e4972 Mon Sep 17 00:00:00 2001 +From: Christos Zoulas +Date: Tue, 26 Jul 2022 15:10:05 +0000 +Subject: [PATCH] Fix bug with large flist (Florian Weimer) + +--- + src/file.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/file.c b/src/file.c +index e169c08fc..c0b8aa197 100644 +--- a/src/file.c ++++ b/src/file.c +@@ -535,6 +535,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); diff --git a/srcpkgs/file/template b/srcpkgs/file/template index 0b2c0c2c70d..3687f0f63da 100644 --- a/srcpkgs/file/template +++ b/srcpkgs/file/template @@ -1,7 +1,6 @@ # Template file for 'file' pkgname=file -reverts="5.42_1" -version=5.41 +version=5.42 revision=2 bootstrap=yes build_style=gnu-configure @@ -12,7 +11,7 @@ maintainer="Enno Boland " license="BSD-2-Clause" homepage="https://www.darwinsys.com/file/" distfiles="https://astron.com/pub/file/file-${version}.tar.gz" -checksum=13e532c7b364f7d57e23dfeea3147103150cb90593a57af86c10e4f6e411603f +checksum=c076fb4d029c74073f15c43361ef572cfb868407d347190ba834af3b1639b0e4 build_options="libseccomp"