diff --git a/backport-comm-fix-NUL-output-delimiter-with-total.patch b/backport-comm-fix-NUL-output-delimiter-with-total.patch deleted file mode 100644 index 1721ebddc71d199acb791fab438d91b636660888..0000000000000000000000000000000000000000 --- a/backport-comm-fix-NUL-output-delimiter-with-total.patch +++ /dev/null @@ -1,86 +0,0 @@ -From 708ae170c987dab83273cb885496e1a8a90233e8 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?P=C3=A1draig=20Brady?= -Date: Sat, 27 Aug 2022 18:40:14 +0100 -Subject: [PATCH] comm: fix NUL --output-delimiter with --total - -* src/comm.c (compare_files): Handle the single character ---output-delimeter case separately so that NUL is appropriately -handled. -* doc/coreutils.texi (comm invocation): Fix the description -of --output-delimiter to say an empty delimeter is treated -as a NUL separator, rather than being disallowed. -* tests/misc/comm.pl: Add a test case. -Reported at https://bugs.debian.org/1014008 - -Reference:https://github.com/coreutils/coreutils/commit/708ae170c987dab83273cb885496e1a8a90233e8 -Conflict:Context adaptation - ---- - doc/coreutils.texi | 3 ++- - src/comm.c | 21 ++++++++++++++++----- - tests/misc/comm.pl | 3 +++ - 3 files changed, 21 insertions(+), 6 deletions(-) - -diff --git a/doc/coreutils.texi b/doc/coreutils.texi -index 9f31f6768..de819b6dc 100644 ---- a/doc/coreutils.texi -+++ b/doc/coreutils.texi -@@ -5427,7 +5427,8 @@ Other options are: - Print @var{str} between adjacent output columns, - rather than the default of a single TAB character. - --The delimiter @var{str} may not be empty. -+The delimiter @var{str} may be empty, in which case -+the ASCII NUL character is used to delimit output columns. - - @item --total - Output a summary at the end. -diff --git a/src/comm.c b/src/comm.c -index 721139cb8..ed9d97d0a 100644 ---- a/src/comm.c -+++ b/src/comm.c -@@ -395,11 +395,22 @@ compare_files (char **infiles) - char buf1[INT_BUFSIZE_BOUND (uintmax_t)]; - char buf2[INT_BUFSIZE_BOUND (uintmax_t)]; - char buf3[INT_BUFSIZE_BOUND (uintmax_t)]; -- printf ("%s%s%s%s%s%s%s%c", -- umaxtostr (total[0], buf1), col_sep, -- umaxtostr (total[1], buf2), col_sep, -- umaxtostr (total[2], buf3), col_sep, -- _("total"), delim); -+ if (col_sep_len == 1) -+ { /* Separate to handle NUL char. */ -+ printf ("%s%c%s%c%s%c%s%c", -+ umaxtostr (total[0], buf1), *col_sep, -+ umaxtostr (total[1], buf2), *col_sep, -+ umaxtostr (total[2], buf3), *col_sep, -+ _("total"), delim); -+ } -+ else -+ { -+ printf ("%s%s%s%s%s%s%s%c", -+ umaxtostr (total[0], buf1), col_sep, -+ umaxtostr (total[1], buf2), col_sep, -+ umaxtostr (total[2], buf3), col_sep, -+ _("total"), delim); -+ } - } - } - -diff --git a/tests/misc/comm.pl b/tests/misc/comm.pl -index 73e8c3720..5d0c4f175 100755 ---- a/tests/misc/comm.pl -+++ b/tests/misc/comm.pl -@@ -157,6 +157,9 @@ my @Tests = - {OUT=>"1\n\0002\n\0002\n\000\0003\n\000\0003\n\000\0003\n"} ], - ['zdelim-empty', '-z', '-z --output-delimiter=', @zinputs, - {OUT=>"1\000\0002\000\0002\000\000\0003\000\000\0003\000\000\0003\000"} ], -+ ['total-delim-empty', '--total --output-delimiter=', @inputs, -+ {OUT=>"1\n\0002\n\0002\n\000\0003\n\000\0003\n\000\0003\n" -+ . "1\0002\0003\000total\n"} ], - - # invalid dual delimiter - ['delim-dual', '--output-delimiter=,', '--output-delimiter=+', @inputs, --- -2.27.0 - diff --git a/backport-copy-copy_file_range-handle-ENOENT-for-CIFS.patch b/backport-copy-copy_file_range-handle-ENOENT-for-CIFS.patch deleted file mode 100644 index 67d555f3e0c6090458d2a8ab630ca12b554beace..0000000000000000000000000000000000000000 --- a/backport-copy-copy_file_range-handle-ENOENT-for-CIFS.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 7fc84d1c0f6b35231b0b4577b70aaa26bf548a7c Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?P=C3=A1draig=20Brady?= -Date: Sat, 7 Jan 2023 16:10:01 +0000 -Subject: [PATCH] copy: copy_file_range: handle ENOENT for CIFS - -* src/copy.c (sparse_copy): Fallback to standard copy upon ENOENT, -which was seen intermittently across CIFS file systems. -* NEWS: Mention the bug fix, though qualify it as an "issue" -rather than a bug, as coreutils is likely only highlighting -a CIFS bug in this case. -Fixes https://bugs.gnu.org/60455 - -Reference:https://github.com/coreutils/coreutils/commit/7fc84d1c0f6b35231b0b4577b70aaa26bf548a7c -Conflict:NEWS context adapation - ---- - NEWS | 4 ++++ - src/copy.c | 5 +++++ - 2 files changed, 9 insertions(+) - -diff --git a/NEWS b/NEWS -index 9d3f253..b65bc85 100644 ---- a/NEWS -+++ b/NEWS -@@ -3,6 +3,10 @@ GNU coreutils NEWS -*- outline -*- - * Noteworthy changes in release 9.0 (2021-09-24) [stable] - - ** Bug fixes -+ cp, mv, and install now handle ENOENT failures across CIFS file systems, -+ falling back from copy_file_range to a better supported standard copy. -+ [issue introduced in coreutils-9.0] -+ - stty now wraps output appropriately for the terminal width. - Previously it may have output 1 character too wide for certain widths. - [bug introduced in coreutils-5.3] -diff --git a/src/copy.c b/src/copy.c -index 519c43b00..98f2ba45a 100644 ---- a/src/copy.c -+++ b/src/copy.c -@@ -290,6 +290,11 @@ sparse_copy (int src_fd, int dest_fd, char **abuf, size_t buf_size, - if (errno == EPERM && *total_n_read == 0) - break; - -+ /* ENOENT was seen sometimes across CIFS shares, resulting in -+ no data being copied, but subsequent standard copies succeed. */ -+ if (errno == ENOENT && *total_n_read == 0) -+ break; -+ - if (errno == EINTR) - n_copied = 0; - else --- -2.27.0 - diff --git a/backport-coreutils-i18n.patch b/backport-coreutils-i18n.patch index c5a6c33ba78579da6c92d24fb17507c9c9dab975..8492fe6acbba139ec5fb5670681126b4df72f1b5 100644 --- a/backport-coreutils-i18n.patch +++ b/backport-coreutils-i18n.patch @@ -1,4 +1,4 @@ -From d53e5b885b9d82e2d9ba5d65ed8fd9b96712623f Mon Sep 17 00:00:00 2001 +From 01010419a6499768563e7b2f3fd56cf16edda75e Mon Sep 17 00:00:00 2001 From: rpm-build Date: Mon, 4 Oct 2021 08:54:37 +0200 Subject: [PATCH] coreutils-i18n.patch @@ -10,16 +10,16 @@ Subject: [PATCH] coreutils-i18n.patch lib/mbfile.c | 3 + lib/mbfile.h | 255 ++++++++++++ m4/mbfile.m4 | 14 + - src/cut.c | 441 +++++++++++++++++++- + src/cut.c | 508 +++++++++++++++++++++-- src/expand-common.c | 114 ++++++ src/expand-common.h | 12 + - src/expand.c | 90 ++++- - src/fold.c | 312 +++++++++++++-- - src/join.c | 359 ++++++++++++++--- + src/expand.c | 90 +++- + src/fold.c | 312 ++++++++++++-- + src/join.c | 359 ++++++++++++++-- src/local.mk | 4 +- - src/pr.c | 443 +++++++++++++++++++-- - src/sort.c | 772 ++++++++++++++++++++++++++++++++++-- - src/unexpand.c | 101 ++++- + src/pr.c | 443 ++++++++++++++++++-- + src/sort.c | 792 +++++++++++++++++++++++++++++++++--- + src/unexpand.c | 102 ++++- src/uniq.c | 119 +++++- tests/Coreutils.pm | 3 + tests/expand/mb.sh | 183 +++++++++ @@ -28,14 +28,14 @@ Subject: [PATCH] coreutils-i18n.patch tests/misc/expand.pl | 42 ++ tests/misc/fold.pl | 50 ++- tests/misc/join.pl | 50 +++ - tests/misc/sort-mb-tests.sh | 45 +++ + tests/misc/sort-mb-tests.sh | 45 ++ tests/misc/sort-merge.pl | 42 ++ tests/misc/sort.pl | 40 +- tests/misc/unexpand.pl | 39 ++ tests/misc/uniq.pl | 55 +++ tests/pr/pr-tests.pl | 49 +++ tests/unexpand/mb.sh | 172 ++++++++ - 31 files changed, 3640 insertions(+), 213 deletions(-) + 31 files changed, 3699 insertions(+), 242 deletions(-) create mode 100644 lib/mbfile.c create mode 100644 lib/mbfile.h create mode 100644 m4/mbfile.m4 @@ -45,10 +45,10 @@ Subject: [PATCH] coreutils-i18n.patch create mode 100755 tests/unexpand/mb.sh diff --git a/bootstrap.conf b/bootstrap.conf -index aef9ec7..9486e9d 100644 +index c1399e3..60b39cf 100644 --- a/bootstrap.conf +++ b/bootstrap.conf -@@ -156,6 +156,7 @@ gnulib_modules=" +@@ -165,6 +165,7 @@ gnulib_modules=" maintainer-makefile malloc-gnu manywarnings @@ -57,10 +57,10 @@ index aef9ec7..9486e9d 100644 mbrtowc mbsalign diff --git a/configure.ac b/configure.ac -index 6960b48..8ff85f8 100644 +index 7e4afc9..4656a35 100644 --- a/configure.ac +++ b/configure.ac -@@ -457,6 +457,8 @@ fi +@@ -477,6 +477,8 @@ fi # I'm leaving it here for now. This whole thing needs to be modernized... gl_WINSIZE_IN_PTEM @@ -70,7 +70,7 @@ index 6960b48..8ff85f8 100644 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \ diff --git a/lib/linebuffer.h b/lib/linebuffer.h -index 5fa5ad2..2bdbcab 100644 +index 07d45ca..af62e6c 100644 --- a/lib/linebuffer.h +++ b/lib/linebuffer.h @@ -22,6 +22,11 @@ @@ -386,7 +386,7 @@ index 0000000..8589902 + : +]) diff --git a/src/cut.c b/src/cut.c -index cdf33d8..b8301d7 100644 +index 6fd8978..faef877 100644 --- a/src/cut.c +++ b/src/cut.c @@ -28,6 +28,11 @@ @@ -401,7 +401,7 @@ index cdf33d8..b8301d7 100644 #include "system.h" #include "error.h" -@@ -37,6 +42,18 @@ +@@ -36,6 +41,18 @@ #include "set-fields.h" @@ -420,7 +420,7 @@ index cdf33d8..b8301d7 100644 /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "cut" -@@ -53,6 +70,52 @@ +@@ -52,6 +69,52 @@ } \ while (0) @@ -473,7 +473,7 @@ index cdf33d8..b8301d7 100644 /* Pointer inside RP. When checking if a byte or field is selected by a finite range, we check if it is between CURRENT_RP.LO -@@ -60,6 +123,9 @@ +@@ -59,6 +122,9 @@ CURRENT_RP.HI then we make CURRENT_RP to point to the next range pair. */ static struct field_range_pair *current_rp; @@ -483,23 +483,26 @@ index cdf33d8..b8301d7 100644 /* This buffer is used to support the semantics of the -s option (or lack of same) when the specified field list includes (does not include) the first field. In both of those cases, the entire -@@ -76,15 +142,25 @@ enum operating_mode - { - undefined_mode, +@@ -71,6 +137,29 @@ static char *field_1_buffer; + /* The number of bytes allocated for FIELD_1_BUFFER. */ + static size_t field_1_bufsize; -- /* Output characters that are in the given bytes. */ ++enum operating_mode ++ { ++ undefined_mode, ++ + /* Output bytes that are at the given positions. */ - byte_mode, - ++ byte_mode, ++ + /* Output characters that are at the given positions. */ + character_mode, + - /* Output the given delimiter-separated fields. */ - field_mode - }; - - static enum operating_mode operating_mode; - ++ /* Output the given delimiter-separated fields. */ ++ field_mode ++ }; ++ ++static enum operating_mode operating_mode; ++ +/* If nonzero, when in byte mode, don't split multibyte characters. */ +static int byte_mode_character_aware; + @@ -510,7 +513,7 @@ index cdf33d8..b8301d7 100644 /* If true do not output lines containing no delimiter characters. Otherwise, all such lines are printed. This option is valid only with field mode. */ -@@ -96,6 +172,9 @@ static bool complement; +@@ -82,10 +171,16 @@ static bool complement; /* The delimiter character for field mode. */ static unsigned char delim; @@ -520,7 +523,24 @@ index cdf33d8..b8301d7 100644 /* The delimiter for each line/record. */ static unsigned char line_delim = '\n'; -@@ -163,7 +242,7 @@ Print selected parts of lines from each FILE to standard output.\n\ + ++/* True if the --output-delimiter=STRING option was specified. */ ++static bool output_delimiter_specified; ++ + /* The length of output_delimiter_string. */ + static size_t output_delimiter_length; + +@@ -93,9 +188,6 @@ static size_t output_delimiter_length; + string consisting of the input delimiter. */ + static char *output_delimiter_string; + +-/* The output delimiter string contents, if the default. */ +-static char output_delimiter_default[1]; +- + /* True if we have ever read standard input. */ + static bool have_read_stdin; + +@@ -149,7 +241,7 @@ Print selected parts of lines from each FILE to standard output.\n\ -f, --fields=LIST select only these fields; also print any line\n\ that contains no delimiter character, unless\n\ the -s option is specified\n\ @@ -529,7 +549,16 @@ index cdf33d8..b8301d7 100644 "), stdout); fputs (_("\ --complement complement the set of selected bytes, characters\n\ -@@ -279,6 +358,82 @@ cut_bytes (FILE *stream) +@@ -249,7 +341,7 @@ cut_bytes (FILE *stream) + next_item (&byte_idx); + if (print_kth (byte_idx)) + { +- if (output_delimiter_string != output_delimiter_default) ++ if (output_delimiter_specified) + { + if (print_delimiter && is_range_start_index (byte_idx)) + { +@@ -265,6 +357,82 @@ cut_bytes (FILE *stream) } } @@ -612,10 +641,11 @@ index cdf33d8..b8301d7 100644 /* Read from stream STREAM, printing to standard output any selected fields. */ static void -@@ -424,13 +579,211 @@ cut_fields (FILE *stream) +@@ -410,11 +578,218 @@ cut_fields (FILE *stream) } } +-/* Process file FILE to standard output, using CUT_STREAM. +#if HAVE_MBRTOWC +static void +cut_fields_mb (FILE *stream) @@ -773,11 +803,9 @@ index cdf33d8..b8301d7 100644 +} +#endif + - static void - cut_stream (FILE *stream) - { -- if (operating_mode == byte_mode) -- cut_bytes (stream); ++static void ++cut_stream (FILE *stream) ++{ +#if HAVE_MBRTOWC + if (MB_CUR_MAX > 1 && !force_singlebyte_mode) + { @@ -815,8 +843,7 @@ index cdf33d8..b8301d7 100644 + abort (); + } + } - else -- cut_fields (stream); ++ else +#endif + { + if (operating_mode == field_mode) @@ -824,29 +851,51 @@ index cdf33d8..b8301d7 100644 + else + cut_bytes (stream); + } - } ++} ++ ++/* Process file FILE to standard output. + Return true if successful. */ + + static bool +-cut_file (char const *file, void (*cut_stream) (FILE *)) ++cut_file (char const *file) + { + FILE *stream; - /* Process file FILE to standard output. -@@ -482,6 +835,7 @@ main (int argc, char **argv) +@@ -458,8 +833,8 @@ main (int argc, char **argv) + int optc; bool ok; bool delim_specified = false; - char *spec_list_string IF_LINT ( = NULL); +- bool byte_mode = false; +- char *spec_list_string = NULL; ++ char *spec_list_string IF_LINT ( = NULL); + char mbdelim[MB_LEN_MAX + 1]; initialize_main (&argc, &argv); set_program_name (argv[0]); -@@ -504,7 +858,6 @@ main (int argc, char **argv) +@@ -469,6 +844,8 @@ main (int argc, char **argv) + + atexit (close_stdout); + ++ operating_mode = undefined_mode; ++ + /* By default, all non-delimited lines are printed. */ + suppress_non_delimited = false; + +@@ -480,35 +857,77 @@ main (int argc, char **argv) switch (optc) { case 'b': - case 'c': /* Build the byte list. */ - if (operating_mode != undefined_mode) - FATAL_ERROR (_("only one type of list may be specified")); -@@ -512,6 +865,14 @@ main (int argc, char **argv) - spec_list_string = optarg; - break; - +- byte_mode = true; +- FALLTHROUGH; ++ if (operating_mode != undefined_mode) ++ FATAL_ERROR (_("only one type of list may be specified")); ++ operating_mode = byte_mode; ++ spec_list_string = optarg; ++ break; ++ + case 'c': + /* Build the character list. */ + if (operating_mode != undefined_mode) @@ -857,8 +906,14 @@ index cdf33d8..b8301d7 100644 + case 'f': /* Build the field list. */ - if (operating_mode != undefined_mode) -@@ -523,10 +884,38 @@ main (int argc, char **argv) +- if (spec_list_string) +- FATAL_ERROR (_("only one list may be specified")); ++ if (operating_mode != undefined_mode) ++ FATAL_ERROR (_("only one type of list may be specified")); ++ operating_mode = field_mode; + spec_list_string = optarg; + break; + case 'd': /* New delimiter. */ /* Interpret -d '' to mean 'use the NUL byte as the delimiter.' */ @@ -901,7 +956,13 @@ index cdf33d8..b8301d7 100644 break; case OUTPUT_DELIMITER_OPTION: -@@ -539,6 +928,7 @@ main (int argc, char **argv) ++ output_delimiter_specified = true; + /* Interpret --output-delimiter='' to mean + 'use the NUL byte as the delimiter.' */ + output_delimiter_length = (optarg[0] == '\0' + ? 1 : strlen (optarg)); +- output_delimiter_string = optarg; ++ output_delimiter_string = xstrdup (optarg); break; case 'n': @@ -909,8 +970,34 @@ index cdf33d8..b8301d7 100644 break; case 's': -@@ -578,15 +968,34 @@ main (int argc, char **argv) - | (complement ? SETFLD_COMPLEMENT : 0) ); +@@ -532,40 +951,57 @@ main (int argc, char **argv) + } + } + +- if (!spec_list_string) ++ if (operating_mode == undefined_mode) + FATAL_ERROR (_("you must specify a list of bytes, characters, or fields")); + +- if (byte_mode) +- { +- if (delim_specified) +- FATAL_ERROR (_("an input delimiter may be specified only\ ++ if (delim_specified && operating_mode != field_mode) ++ FATAL_ERROR (_("an input delimiter may be specified only\ + when operating on fields")); + +- if (suppress_non_delimited) +- FATAL_ERROR (_("suppressing non-delimited lines makes sense\n\ ++ if (suppress_non_delimited && operating_mode != field_mode) ++ FATAL_ERROR (_("suppressing non-delimited lines makes sense\n\ + \tonly when operating on fields")); +- } + + set_fields (spec_list_string, +- ((byte_mode ? SETFLD_ERRMSG_USE_POS : 0) +- | (complement ? SETFLD_COMPLEMENT : 0))); ++ ( (operating_mode == field_mode) ? 0 : SETFLD_ERRMSG_USE_POS) ++ | (complement ? SETFLD_COMPLEMENT : 0) ); if (!delim_specified) - delim = '\t'; @@ -926,10 +1013,8 @@ index cdf33d8..b8301d7 100644 if (output_delimiter_string == NULL) { -- static char dummy[2]; -- dummy[0] = delim; -- dummy[1] = '\0'; -- output_delimiter_string = dummy; +- output_delimiter_default[0] = delim; +- output_delimiter_string = output_delimiter_default; - output_delimiter_length = 1; +#ifdef HAVE_MBRTOWC + if (MB_CUR_MAX > 1 && !force_singlebyte_mode) @@ -949,9 +1034,19 @@ index cdf33d8..b8301d7 100644 + } } +- void (*cut_stream) (FILE *) = byte_mode ? cut_bytes : cut_fields; if (optind == argc) +- ok = cut_file ("-", cut_stream); ++ ok = cut_file ("-"); + else + for (ok = true; optind < argc; optind++) +- ok &= cut_file (argv[optind], cut_stream); ++ ok &= cut_file (argv[optind]); + + + if (have_read_stdin && fclose (stdin) == EOF) diff --git a/src/expand-common.c b/src/expand-common.c -index 4deb7bd..8fd0524 100644 +index deec1bd..b39f740 100644 --- a/src/expand-common.c +++ b/src/expand-common.c @@ -19,6 +19,7 @@ @@ -1083,7 +1178,7 @@ index 4deb7bd..8fd0524 100644 to the list of tab stops. */ extern void diff --git a/src/expand-common.h b/src/expand-common.h -index ac812d0..16789ab 100644 +index 5f59a0e..835b9d5 100644 --- a/src/expand-common.h +++ b/src/expand-common.h @@ -25,6 +25,18 @@ extern size_t max_column_width; @@ -1106,7 +1201,7 @@ index ac812d0..16789ab 100644 extern void add_tab_stop (uintmax_t tabval); diff --git a/src/expand.c b/src/expand.c -index 4e32bfc..902c6b4 100644 +index ed78ca8..a4cefa1 100644 --- a/src/expand.c +++ b/src/expand.c @@ -37,6 +37,9 @@ @@ -1262,7 +1357,7 @@ index 4e32bfc..902c6b4 100644 } diff --git a/src/fold.c b/src/fold.c -index 94a6d37..a278783 100644 +index f07a90b..d32dbfd 100644 --- a/src/fold.c +++ b/src/fold.c @@ -22,12 +22,34 @@ @@ -1668,7 +1763,7 @@ index 94a6d37..a278783 100644 case 's': /* Break at word boundaries. */ diff --git a/src/join.c b/src/join.c -index f22ffda..ad5dc0d 100644 +index f2fd172..6c7d1ed 100644 --- a/src/join.c +++ b/src/join.c @@ -22,19 +22,33 @@ @@ -1723,7 +1818,7 @@ index f22ffda..ad5dc0d 100644 /* If nonzero, check that the input is correctly ordered. */ static enum -@@ -276,13 +292,14 @@ xfields (struct line *line) +@@ -280,13 +296,14 @@ xfields (struct line *line) if (ptr == lim) return; @@ -1741,7 +1836,7 @@ index f22ffda..ad5dc0d 100644 { /* Skip leading blanks before the first field. */ while (field_sep (*ptr)) -@@ -306,6 +323,147 @@ xfields (struct line *line) +@@ -310,6 +327,147 @@ xfields (struct line *line) extract_field (line, ptr, lim - ptr); } @@ -1889,7 +1984,7 @@ index f22ffda..ad5dc0d 100644 static void freeline (struct line *line) { -@@ -327,56 +485,133 @@ keycmp (struct line const *line1, struct line const *line2, +@@ -331,56 +489,133 @@ keycmp (struct line const *line1, struct line const *line2, size_t jf_1, size_t jf_2) { /* Start of field to compare in each file. */ @@ -2041,12 +2136,12 @@ index f22ffda..ad5dc0d 100644 + if (diff) return diff; -- return len1 < len2 ? -1 : len1 != len2; +- return (len1 > len2) - (len1 < len2); + return len[0] - len[1]; } /* Check that successive input lines PREV and CURRENT from input file -@@ -468,6 +703,11 @@ get_line (FILE *fp, struct line **linep, int which) +@@ -472,6 +707,11 @@ get_line (FILE *fp, struct line **linep, int which) } ++line_no[which - 1]; @@ -2058,7 +2153,7 @@ index f22ffda..ad5dc0d 100644 xfields (line); if (prevline[which - 1]) -@@ -563,21 +803,28 @@ prfield (size_t n, struct line const *line) +@@ -567,21 +807,28 @@ prfield (size_t n, struct line const *line) /* Output all the fields in line, other than the join field. */ @@ -2090,7 +2185,7 @@ index f22ffda..ad5dc0d 100644 prfield (i, line); } } -@@ -588,7 +835,6 @@ static void +@@ -592,7 +839,6 @@ static void prjoin (struct line const *line1, struct line const *line2) { const struct outlist *outlist; @@ -2098,7 +2193,7 @@ index f22ffda..ad5dc0d 100644 size_t field; struct line const *line; -@@ -622,7 +868,7 @@ prjoin (struct line const *line1, struct line const *line2) +@@ -626,7 +872,7 @@ prjoin (struct line const *line1, struct line const *line2) o = o->next; if (o == NULL) break; @@ -2107,7 +2202,7 @@ index f22ffda..ad5dc0d 100644 } putchar (eolchar); } -@@ -1098,20 +1344,43 @@ main (int argc, char **argv) +@@ -1102,20 +1348,43 @@ main (int argc, char **argv) case 't': { @@ -2161,10 +2256,10 @@ index f22ffda..ad5dc0d 100644 break; diff --git a/src/local.mk b/src/local.mk -index 0c8b65d..011421a 100644 +index e1d15ce..1a5ffaa 100644 --- a/src/local.mk +++ b/src/local.mk -@@ -429,8 +429,8 @@ src_base32_CPPFLAGS = -DBASE_TYPE=32 $(AM_CPPFLAGS) +@@ -438,8 +438,8 @@ src_base32_CPPFLAGS = -DBASE_TYPE=32 $(AM_CPPFLAGS) src_basenc_SOURCES = src/basenc.c src_basenc_CPPFLAGS = -DBASE_TYPE=42 $(AM_CPPFLAGS) @@ -2176,7 +2271,7 @@ index 0c8b65d..011421a 100644 src_wc_SOURCES = src/wc.c if USE_AVX2_WC_LINECOUNT diff --git a/src/pr.c b/src/pr.c -index 8f84d0f..4bb5195 100644 +index 4c17c00..b4fab1c 100644 --- a/src/pr.c +++ b/src/pr.c @@ -311,6 +311,24 @@ @@ -2314,7 +2409,7 @@ index 8f84d0f..4bb5195 100644 static char *column_separator = (char *) " "; static char *line_separator = (char *) "\t"; -@@ -852,6 +905,13 @@ separator_string (char const *optarg_S) +@@ -853,6 +906,13 @@ separator_string (char const *optarg_S) integer_overflow (); col_sep_length = len; col_sep_string = optarg_S; @@ -2328,7 +2423,7 @@ index 8f84d0f..4bb5195 100644 } int -@@ -876,6 +936,21 @@ main (int argc, char **argv) +@@ -877,6 +937,21 @@ main (int argc, char **argv) atexit (close_stdout); @@ -2350,7 +2445,7 @@ index 8f84d0f..4bb5195 100644 n_files = 0; file_names = (argc > 1 ? xnmalloc (argc - 1, sizeof (char *)) -@@ -952,8 +1027,12 @@ main (int argc, char **argv) +@@ -953,8 +1028,12 @@ main (int argc, char **argv) break; case 'e': if (optarg) @@ -2365,7 +2460,7 @@ index 8f84d0f..4bb5195 100644 /* Could check tab width > 0. */ untabify_input = true; break; -@@ -966,8 +1045,12 @@ main (int argc, char **argv) +@@ -967,8 +1046,12 @@ main (int argc, char **argv) break; case 'i': if (optarg) @@ -2380,7 +2475,7 @@ index 8f84d0f..4bb5195 100644 /* Could check tab width > 0. */ tabify_output = true; break; -@@ -985,8 +1068,8 @@ main (int argc, char **argv) +@@ -986,8 +1069,8 @@ main (int argc, char **argv) case 'n': numbered_lines = true; if (optarg) @@ -2391,7 +2486,7 @@ index 8f84d0f..4bb5195 100644 break; case 'N': skip_count = false; -@@ -1011,6 +1094,7 @@ main (int argc, char **argv) +@@ -1012,6 +1095,7 @@ main (int argc, char **argv) /* Reset an additional input of -s, -S dominates -s */ col_sep_string = ""; col_sep_length = 0; @@ -2447,7 +2542,7 @@ index 8f84d0f..4bb5195 100644 if (*arg) { long int tmp_long; -@@ -1191,6 +1310,11 @@ static void +@@ -1198,6 +1317,11 @@ static void init_parameters (int number_of_files) { int chars_used_by_number = 0; @@ -2459,7 +2554,7 @@ index 8f84d0f..4bb5195 100644 lines_per_body = lines_per_page - lines_per_header - lines_per_footer; if (lines_per_body <= 0) -@@ -1228,7 +1352,7 @@ init_parameters (int number_of_files) +@@ -1235,7 +1359,7 @@ init_parameters (int number_of_files) else col_sep_string = column_separator; @@ -2468,7 +2563,7 @@ index 8f84d0f..4bb5195 100644 use_col_separator = true; } /* It's rather pointless to define a TAB separator with column -@@ -1260,11 +1384,11 @@ init_parameters (int number_of_files) +@@ -1267,11 +1391,11 @@ init_parameters (int number_of_files) + TAB_WIDTH (chars_per_input_tab, chars_per_number); */ /* Estimate chars_per_text without any margin and keep it constant. */ @@ -2482,7 +2577,7 @@ index 8f84d0f..4bb5195 100644 /* The number is part of the column width unless we are printing files in parallel. */ -@@ -1273,7 +1397,7 @@ init_parameters (int number_of_files) +@@ -1280,7 +1404,7 @@ init_parameters (int number_of_files) } int sep_chars, useful_chars; @@ -2491,7 +2586,7 @@ index 8f84d0f..4bb5195 100644 sep_chars = INT_MAX; if (INT_SUBTRACT_WRAPV (chars_per_line - chars_used_by_number, sep_chars, &useful_chars)) -@@ -1296,7 +1420,7 @@ init_parameters (int number_of_files) +@@ -1303,7 +1427,7 @@ init_parameters (int number_of_files) We've to use 8 as the lower limit, if we use chars_per_default_tab = 8 to expand a tab which is not an input_tab-char. */ free (clump_buff); @@ -2500,7 +2595,7 @@ index 8f84d0f..4bb5195 100644 } /* Open the necessary files, -@@ -1402,7 +1526,7 @@ init_funcs (void) +@@ -1409,7 +1533,7 @@ init_funcs (void) /* Enlarge p->start_position of first column to use the same form of padding_not_printed with all columns. */ @@ -2509,7 +2604,7 @@ index 8f84d0f..4bb5195 100644 /* This loop takes care of all but the rightmost column. */ -@@ -1436,7 +1560,7 @@ init_funcs (void) +@@ -1443,7 +1567,7 @@ init_funcs (void) } else { @@ -2518,7 +2613,7 @@ index 8f84d0f..4bb5195 100644 h_next = h + chars_per_column; } } -@@ -1733,9 +1857,9 @@ static void +@@ -1740,9 +1864,9 @@ static void align_column (COLUMN *p) { padding_not_printed = p->start_position; @@ -2530,7 +2625,7 @@ index 8f84d0f..4bb5195 100644 padding_not_printed = ANYWHERE; } -@@ -2010,13 +2134,13 @@ store_char (char c) +@@ -2017,13 +2141,13 @@ store_char (char c) /* May be too generous. */ buff = X2REALLOC (buff, &buff_allocated); } @@ -2546,7 +2641,7 @@ index 8f84d0f..4bb5195 100644 char *s; int num_width; -@@ -2033,22 +2157,24 @@ add_line_number (COLUMN *p) +@@ -2040,22 +2164,24 @@ add_line_number (COLUMN *p) /* Tabification is assumed for multiple columns, also for n-separators, but 'default n-separator = TAB' hasn't been given priority over equal column_width also specified by POSIX. */ @@ -2575,7 +2670,7 @@ index 8f84d0f..4bb5195 100644 output_position = POS_AFTER_TAB (chars_per_output_tab, output_position); } -@@ -2207,7 +2333,7 @@ print_white_space (void) +@@ -2214,7 +2340,7 @@ print_white_space (void) while (goal - h_old > 1 && (h_new = POS_AFTER_TAB (chars_per_output_tab, h_old)) <= goal) { @@ -2584,7 +2679,7 @@ index 8f84d0f..4bb5195 100644 h_old = h_new; } while (++h_old <= goal) -@@ -2227,6 +2353,7 @@ print_sep_string (void) +@@ -2234,6 +2360,7 @@ print_sep_string (void) { char const *s = col_sep_string; int l = col_sep_length; @@ -2592,7 +2687,7 @@ index 8f84d0f..4bb5195 100644 if (separators_not_printed <= 0) { -@@ -2238,6 +2365,7 @@ print_sep_string (void) +@@ -2245,6 +2372,7 @@ print_sep_string (void) { for (; separators_not_printed > 0; --separators_not_printed) { @@ -2600,7 +2695,7 @@ index 8f84d0f..4bb5195 100644 while (l-- > 0) { /* 3 types of sep_strings: spaces only, spaces and chars, -@@ -2251,12 +2379,15 @@ print_sep_string (void) +@@ -2258,12 +2386,15 @@ print_sep_string (void) } else { @@ -2617,7 +2712,7 @@ index 8f84d0f..4bb5195 100644 /* sep_string ends with some spaces */ if (spaces_not_printed > 0) print_white_space (); -@@ -2284,7 +2415,7 @@ print_clump (COLUMN *p, int n, char *clump) +@@ -2291,7 +2422,7 @@ print_clump (COLUMN *p, int n, char *clump) required number of tabs and spaces. */ static void @@ -2626,7 +2721,7 @@ index 8f84d0f..4bb5195 100644 { if (tabify_output) { -@@ -2308,6 +2439,74 @@ print_char (char c) +@@ -2315,6 +2446,74 @@ print_char (char c) putchar (c); } @@ -2701,7 +2796,7 @@ index 8f84d0f..4bb5195 100644 /* Skip to page PAGE before printing. PAGE may be larger than total number of pages. */ -@@ -2485,9 +2684,9 @@ read_line (COLUMN *p) +@@ -2492,9 +2691,9 @@ read_line (COLUMN *p) align_empty_cols = false; } @@ -2713,7 +2808,7 @@ index 8f84d0f..4bb5195 100644 padding_not_printed = ANYWHERE; } -@@ -2556,7 +2755,7 @@ print_stored (COLUMN *p) +@@ -2563,7 +2762,7 @@ print_stored (COLUMN *p) COLUMN *q; int line = p->current_line++; @@ -2722,7 +2817,7 @@ index 8f84d0f..4bb5195 100644 /* FIXME UMR: Uninitialized memory read: * This is occurring while in: -@@ -2568,7 +2767,7 @@ print_stored (COLUMN *p) +@@ -2575,7 +2774,7 @@ print_stored (COLUMN *p) xmalloc [xmalloc.c:94] init_store_cols [pr.c:1648] */ @@ -2731,7 +2826,7 @@ index 8f84d0f..4bb5195 100644 pad_vertically = true; -@@ -2588,9 +2787,9 @@ print_stored (COLUMN *p) +@@ -2595,9 +2794,9 @@ print_stored (COLUMN *p) } } @@ -2743,7 +2838,7 @@ index 8f84d0f..4bb5195 100644 padding_not_printed = ANYWHERE; } -@@ -2603,8 +2802,8 @@ print_stored (COLUMN *p) +@@ -2610,8 +2809,8 @@ print_stored (COLUMN *p) if (spaces_not_printed == 0) { output_position = p->start_position + end_vector[line]; @@ -2754,7 +2849,7 @@ index 8f84d0f..4bb5195 100644 } return true; -@@ -2623,7 +2822,7 @@ print_stored (COLUMN *p) +@@ -2630,7 +2829,7 @@ print_stored (COLUMN *p) number of characters is 1.) */ static int @@ -2763,7 +2858,7 @@ index 8f84d0f..4bb5195 100644 { unsigned char uc = c; char *s = clump_buff; -@@ -2633,10 +2832,10 @@ char_to_clump (char c) +@@ -2640,10 +2839,10 @@ char_to_clump (char c) int chars; int chars_per_c = 8; @@ -2776,7 +2871,7 @@ index 8f84d0f..4bb5195 100644 { width = TAB_WIDTH (chars_per_c, input_position); -@@ -2717,6 +2916,164 @@ char_to_clump (char c) +@@ -2724,6 +2923,164 @@ char_to_clump (char c) return chars; } @@ -2942,7 +3037,7 @@ index 8f84d0f..4bb5195 100644 looking for more options and printing the next batch of files. diff --git a/src/sort.c b/src/sort.c -index 5f4c817..bd9c672 100644 +index 3b775d6..a0ba243 100644 --- a/src/sort.c +++ b/src/sort.c @@ -29,6 +29,14 @@ @@ -2960,9 +3055,9 @@ index 5f4c817..bd9c672 100644 #include "system.h" #include "argmatch.h" #include "die.h" -@@ -157,14 +165,39 @@ static int decimal_point; - /* Thousands separator; if -1, then there isn't one. */ - static int thousands_sep; +@@ -159,14 +167,39 @@ static int thousands_sep; + /* We currently ignore multi-byte grouping chars. */ + static bool thousands_sep_ignored; +/* True if -f is specified. */ +static bool folding; @@ -3001,9 +3096,9 @@ index 5f4c817..bd9c672 100644 /* The kind of blanks for '-b' to skip in various options. */ enum blanktype { bl_start, bl_end, bl_both }; -@@ -338,13 +371,11 @@ static bool reverse; - they were read if all keys compare equal. */ - static bool stable; +@@ -343,13 +376,11 @@ static bool stable; + /* An int value outside char range. */ + enum { NON_CHAR = CHAR_MAX + 1 }; -/* If TAB has this value, blanks separate fields. */ -enum { TAB_DEFAULT = CHAR_MAX + 1 }; @@ -3018,7 +3113,7 @@ index 5f4c817..bd9c672 100644 /* Flag to remove consecutive duplicate lines from the output. Only the last of a sequence of equal lines will be output. */ -@@ -802,6 +833,46 @@ reap_all (void) +@@ -805,6 +836,46 @@ reap_all (void) reap (-1); } @@ -3065,7 +3160,7 @@ index 5f4c817..bd9c672 100644 /* Clean up any remaining temporary files. */ static void -@@ -1269,7 +1340,7 @@ zaptemp (char const *name) +@@ -1272,7 +1343,7 @@ zaptemp (char const *name) free (node); } @@ -3074,7 +3169,7 @@ index 5f4c817..bd9c672 100644 static int struct_month_cmp (void const *m1, void const *m2) -@@ -1284,7 +1355,7 @@ struct_month_cmp (void const *m1, void const *m2) +@@ -1287,7 +1358,7 @@ struct_month_cmp (void const *m1, void const *m2) /* Initialize the character class tables. */ static void @@ -3083,7 +3178,7 @@ index 5f4c817..bd9c672 100644 { size_t i; -@@ -1296,7 +1367,7 @@ inittables (void) +@@ -1299,7 +1370,7 @@ inittables (void) fold_toupper[i] = toupper (i); } @@ -3092,7 +3187,7 @@ index 5f4c817..bd9c672 100644 /* If we're not in the "C" locale, read different names for months. */ if (hard_LC_TIME) { -@@ -1378,6 +1449,84 @@ specify_nmerge (int oi, char c, char const *s) +@@ -1381,6 +1452,84 @@ specify_nmerge (int oi, char c, char const *s) xstrtol_fatal (e, oi, c, long_options, s); } @@ -3177,7 +3272,7 @@ index 5f4c817..bd9c672 100644 /* Specify the amount of main memory to use when sorting. */ static void specify_sort_size (int oi, char c, char const *s) -@@ -1609,7 +1758,7 @@ buffer_linelim (struct buffer const *buf) +@@ -1612,7 +1761,7 @@ buffer_linelim (struct buffer const *buf) by KEY in LINE. */ static char * @@ -3186,7 +3281,7 @@ index 5f4c817..bd9c672 100644 { char *ptr = line->text, *lim = ptr + line->length - 1; size_t sword = key->sword; -@@ -1618,10 +1767,10 @@ begfield (struct line const *line, struct keyfield const *key) +@@ -1621,10 +1770,10 @@ begfield (struct line const *line, struct keyfield const *key) /* The leading field separator itself is included in a field when -t is absent. */ @@ -3199,7 +3294,7 @@ index 5f4c817..bd9c672 100644 ++ptr; if (ptr < lim) ++ptr; -@@ -1647,11 +1796,70 @@ begfield (struct line const *line, struct keyfield const *key) +@@ -1650,12 +1799,71 @@ begfield (struct line const *line, struct keyfield const *key) return ptr; } @@ -3265,13 +3360,14 @@ index 5f4c817..bd9c672 100644 /* Return the limit of (a pointer to the first character after) the field in LINE specified by KEY. */ - static char * _GL_ATTRIBUTE_PURE + ATTRIBUTE_PURE + static char * -limfield (struct line const *line, struct keyfield const *key) +limfield_uni (struct line const *line, struct keyfield const *key) { char *ptr = line->text, *lim = ptr + line->length - 1; size_t eword = key->eword, echar = key->echar; -@@ -1666,10 +1874,10 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1670,10 +1878,10 @@ limfield (struct line const *line, struct keyfield const *key) 'beginning' is the first character following the delimiting TAB. Otherwise, leave PTR pointing at the first 'blank' character after the preceding field. */ @@ -3284,7 +3380,7 @@ index 5f4c817..bd9c672 100644 ++ptr; if (ptr < lim && (eword || echar)) ++ptr; -@@ -1715,10 +1923,10 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1719,10 +1927,10 @@ limfield (struct line const *line, struct keyfield const *key) */ /* Make LIM point to the end of (one byte past) the current field. */ @@ -3297,7 +3393,7 @@ index 5f4c817..bd9c672 100644 if (newlim) lim = newlim; } -@@ -1749,6 +1957,130 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1753,6 +1961,130 @@ limfield (struct line const *line, struct keyfield const *key) return ptr; } @@ -3428,7 +3524,7 @@ index 5f4c817..bd9c672 100644 /* Fill BUF reading from FP, moving buf->left bytes from the end of buf->buf to the beginning first. If EOF is reached and the file wasn't terminated by a newline, supply one. Set up BUF's line -@@ -1835,8 +2167,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) +@@ -1839,8 +2171,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) else { if (key->skipsblanks) @@ -3453,9 +3549,9 @@ index 5f4c817..bd9c672 100644 line->keybeg = line_start; } } -@@ -1970,12 +2316,10 @@ find_unit_order (char const *number) - < K/k < M < G < T < P < E < Z < Y */ +@@ -1978,12 +2324,10 @@ find_unit_order (char const *number) + ATTRIBUTE_PURE static int -human_numcompare (char const *a, char const *b) +human_numcompare (char *a, char *b) @@ -3469,16 +3565,16 @@ index 5f4c817..bd9c672 100644 int diff = find_unit_order (a) - find_unit_order (b); return (diff ? diff : strnumcmp (a, b, decimal_point, thousands_sep)); -@@ -1986,7 +2330,7 @@ human_numcompare (char const *a, char const *b) - hideously fast. */ +@@ -1995,7 +2339,7 @@ human_numcompare (char const *a, char const *b) + ATTRIBUTE_PURE static int -numcompare (char const *a, char const *b) +numcompare_uni (const char *a, const char *b) { while (blanks[to_uchar (*a)]) a++; -@@ -1996,6 +2340,25 @@ numcompare (char const *a, char const *b) +@@ -2005,6 +2349,25 @@ numcompare (char const *a, char const *b) return strnumcmp (a, b, decimal_point, thousands_sep); } @@ -3501,9 +3597,9 @@ index 5f4c817..bd9c672 100644 +} +#endif /* HAV_EMBRTOWC */ + - /* Work around a problem whereby the long double value returned by glibc's - strtold ("NaN", ...) contains uninitialized bits: clear all bytes of - A and B before calling strtold. FIXME: remove this function if + static int + nan_compare (long double a, long double b) + { @@ -2046,7 +2409,7 @@ general_numcompare (char const *sa, char const *sb) Return 0 if the name in S is not recognized. */ @@ -3531,7 +3627,7 @@ index 5f4c817..bd9c672 100644 else if (key->general_numeric) ignore_value (strtold (beg, &tighter_lim)); else if (key->numeric || key->human_numeric) -@@ -2464,7 +2826,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2476,7 +2838,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) /* Warn about significant leading blanks. */ bool implicit_skip = key_numeric (key) || key->month; bool line_offset = key->eword == 0 && key->echar != 0; /* -k1.x,1.y */ @@ -3540,8 +3636,67 @@ index 5f4c817..bd9c672 100644 && ((!key->skipsblanks && !implicit_skip) || (!key->skipsblanks && key->schar) || (!key->skipeblanks && key->echar))) -@@ -2522,11 +2884,87 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) - error (0, 0, _("option '-r' only applies to last-resort comparison")); +@@ -2524,9 +2886,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) + bool number_locale_warned = false; + if (basic_numeric_field_span) + { +- if (tab == TAB_DEFAULT +- ? thousands_sep != NON_CHAR && (isblank (to_uchar (thousands_sep))) +- : tab == thousands_sep) ++ if (tab_length ++ ? tab[0] == thousands_sep ++ : thousands_sep != NON_CHAR && (isblank (to_uchar (thousands_sep)))) + { + error (0, 0, + _("field separator %s is treated as a " +@@ -2537,9 +2899,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) + } + if (basic_numeric_field_span || general_numeric_field_span) + { +- if (tab == TAB_DEFAULT +- ? thousands_sep != NON_CHAR && (isblank (to_uchar (decimal_point))) +- : tab == decimal_point) ++ if (tab_length ++ ? tab[0] == decimal_point ++ : thousands_sep != NON_CHAR && (isblank (to_uchar (decimal_point)))) + { + error (0, 0, + _("field separator %s is treated as a " +@@ -2547,19 +2909,19 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) + quote (((char []) {decimal_point, 0}))); + number_locale_warned = true; + } +- else if (tab == '-') ++ else if (tab_length && tab[0] == '-') + { + error (0, 0, + _("field separator %s is treated as a " + "minus sign in numbers"), +- quote (((char []) {tab, 0}))); ++ quote (((char []) {tab[0], 0}))); + } +- else if (general_numeric_field_span && tab == '+') ++ else if (general_numeric_field_span && tab_length && tab[0] == '+') + { + error (0, 0, + _("field separator %s is treated as a " + "plus sign in numbers"), +- quote (((char []) {tab, 0}))); ++ quote (((char []) {tab[0], 0}))); + } + } + +@@ -2570,7 +2932,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) + { + error (0, 0, + _("%snumbers use %s as a decimal point in this locale"), +- tab == decimal_point ? "" : _("note "), ++ (tab_length && tab[0] == decimal_point) ? "" : _("note "), + quote (((char []) {decimal_point, 0}))); + + } +@@ -2612,11 +2974,87 @@ diff_reversed (int diff, bool reversed) + return reversed ? (diff < 0) - (diff > 0) : diff; } +#if HAVE_MBRTOWC @@ -3629,7 +3784,7 @@ index 5f4c817..bd9c672 100644 { struct keyfield *key = keylist; -@@ -2611,7 +3049,7 @@ keycompare (struct line const *a, struct line const *b) +@@ -2697,7 +3135,7 @@ keycompare (struct line const *a, struct line const *b) else if (key->human_numeric) diff = human_numcompare (ta, tb); else if (key->month) @@ -3638,8 +3793,8 @@ index 5f4c817..bd9c672 100644 else if (key->random) diff = compare_random (ta, tlena, tb, tlenb); else if (key->version) -@@ -2727,6 +3165,211 @@ keycompare (struct line const *a, struct line const *b) - return key->reverse ? -diff : diff; +@@ -2807,6 +3245,211 @@ keycompare (struct line const *a, struct line const *b) + return diff_reversed (diff, key->reverse); } +#if HAVE_MBRTOWC @@ -3850,7 +4005,7 @@ index 5f4c817..bd9c672 100644 /* Compare two lines A and B, returning negative, zero, or positive depending on whether A compares less than, equal to, or greater than B. */ -@@ -2754,7 +3397,7 @@ compare (struct line const *a, struct line const *b) +@@ -2834,7 +3477,7 @@ compare (struct line const *a, struct line const *b) diff = - NONZERO (blen); else if (blen == 0) diff = 1; @@ -3859,7 +4014,7 @@ index 5f4c817..bd9c672 100644 { /* xmemcoll0 is a performance enhancement as it will not unconditionally write '\0' after the -@@ -4144,6 +4787,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) +@@ -4222,6 +4865,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) break; case 'f': key->translate = fold_toupper; @@ -3867,7 +4022,7 @@ index 5f4c817..bd9c672 100644 break; case 'g': key->general_numeric = true; -@@ -4223,7 +4867,7 @@ main (int argc, char **argv) +@@ -4301,7 +4945,7 @@ main (int argc, char **argv) initialize_exit_failure (SORT_FAILURE); hard_LC_COLLATE = hard_locale (LC_COLLATE); @@ -3876,8 +4031,8 @@ index 5f4c817..bd9c672 100644 hard_LC_TIME = hard_locale (LC_TIME); #endif -@@ -4244,6 +4888,29 @@ main (int argc, char **argv) - thousands_sep = -1; +@@ -4324,6 +4968,29 @@ main (int argc, char **argv) + thousands_sep = NON_CHAR; } +#if HAVE_MBRTOWC @@ -3906,7 +4061,7 @@ index 5f4c817..bd9c672 100644 have_read_stdin = false; inittables (); -@@ -4518,13 +5185,34 @@ main (int argc, char **argv) +@@ -4598,13 +5265,34 @@ main (int argc, char **argv) case 't': { @@ -3945,7 +4100,7 @@ index 5f4c817..bd9c672 100644 else { /* Provoke with 'sort -txx'. Complain about -@@ -4535,9 +5223,11 @@ main (int argc, char **argv) +@@ -4615,9 +5303,11 @@ main (int argc, char **argv) quote (optarg)); } } @@ -3959,21 +4114,8 @@ index 5f4c817..bd9c672 100644 } break; -@@ -4766,12 +5456,10 @@ main (int argc, char **argv) - sort (files, nfiles, outfile, nthreads); - } - --#ifdef lint - if (files_from) - readtokens0_free (&tok); - else - free (files); --#endif - - if (have_read_stdin && fclose (stdin) == EOF) - sort_die (_("close failed"), "-"); diff --git a/src/unexpand.c b/src/unexpand.c -index cec392d..483f0ef 100644 +index 7d6100f..04cd646 100644 --- a/src/unexpand.c +++ b/src/unexpand.c @@ -38,6 +38,9 @@ @@ -4178,7 +4320,7 @@ index cec392d..483f0ef 100644 } diff --git a/src/uniq.c b/src/uniq.c -index 8f6e973..752797a 100644 +index e5996f0..871d47c 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -21,6 +21,17 @@ @@ -4229,16 +4371,16 @@ index 8f6e973..752797a 100644 static struct option const longopts[] = { {"count", no_argument, NULL, 'c'}, -@@ -253,7 +280,7 @@ size_opt (char const *opt, char const *msgid) - return a pointer to the beginning of the line's field to be compared. */ +@@ -254,7 +281,7 @@ size_opt (char const *opt, char const *msgid) - static char * _GL_ATTRIBUTE_PURE + ATTRIBUTE_PURE + static char * -find_field (struct linebuffer const *line) +find_field_uni (struct linebuffer *line) { size_t count; char const *lp = line->buffer; -@@ -273,6 +300,83 @@ find_field (struct linebuffer const *line) +@@ -274,6 +301,83 @@ find_field (struct linebuffer const *line) return line->buffer + i; } @@ -4322,7 +4464,7 @@ index 8f6e973..752797a 100644 /* Return false if two strings OLD and NEW match, true if not. OLD and NEW point not to the beginnings of the lines but rather to the beginnings of the fields to compare. -@@ -493,6 +597,19 @@ main (int argc, char **argv) +@@ -494,6 +598,19 @@ main (int argc, char **argv) atexit (close_stdout); @@ -4343,7 +4485,7 @@ index 8f6e973..752797a 100644 skip_fields = 0; check_chars = SIZE_MAX; diff --git a/tests/Coreutils.pm b/tests/Coreutils.pm -index dc6b132..a2abc6d 100644 +index fad7ab9..c9021a6 100644 --- a/tests/Coreutils.pm +++ b/tests/Coreutils.pm @@ -269,6 +269,9 @@ sub run_tests ($$$$$) @@ -4581,10 +4723,10 @@ index 0000000..26c95de + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk -index 228d0e3..a76c808 100644 +index 0f77786..dbe1843 100644 --- a/tests/local.mk +++ b/tests/local.mk -@@ -375,6 +375,8 @@ all_tests = \ +@@ -381,6 +381,8 @@ all_tests = \ tests/misc/sort-discrim.sh \ tests/misc/sort-files0-from.pl \ tests/misc/sort-float.sh \ @@ -4593,7 +4735,7 @@ index 228d0e3..a76c808 100644 tests/misc/sort-h-thousands-sep.sh \ tests/misc/sort-merge.pl \ tests/misc/sort-merge-fdlimit.sh \ -@@ -573,6 +575,7 @@ all_tests = \ +@@ -582,6 +584,7 @@ all_tests = \ tests/du/threshold.sh \ tests/du/trailing-slash.sh \ tests/du/two-args.sh \ @@ -4601,7 +4743,7 @@ index 228d0e3..a76c808 100644 tests/id/gnu-zero-uids.sh \ tests/id/no-context.sh \ tests/id/context.sh \ -@@ -724,6 +727,7 @@ all_tests = \ +@@ -734,6 +737,7 @@ all_tests = \ tests/touch/read-only.sh \ tests/touch/relative.sh \ tests/touch/trailing-slash.sh \ @@ -4610,7 +4752,7 @@ index 228d0e3..a76c808 100644 # See tests/factor/create-test.sh. diff --git a/tests/misc/expand.pl b/tests/misc/expand.pl -index a10ff19..e1706c1 100755 +index 7a77e6f..27f6652 100755 --- a/tests/misc/expand.pl +++ b/tests/misc/expand.pl @@ -27,6 +27,15 @@ my $prog = 'expand'; @@ -4677,7 +4819,7 @@ index a10ff19..e1706c1 100755 my $verbose = $ENV{VERBOSE}; diff --git a/tests/misc/fold.pl b/tests/misc/fold.pl -index beacec9..b56afca 100755 +index 2834f92..bc1616a 100755 --- a/tests/misc/fold.pl +++ b/tests/misc/fold.pl @@ -20,9 +20,18 @@ use strict; @@ -4750,7 +4892,7 @@ index beacec9..b56afca 100755 my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); exit $fail; diff --git a/tests/misc/join.pl b/tests/misc/join.pl -index bfd9e6f..75788c9 100755 +index 06ad777..be40204 100755 --- a/tests/misc/join.pl +++ b/tests/misc/join.pl @@ -25,6 +25,15 @@ my $limits = getlimits (); @@ -4871,7 +5013,7 @@ index 0000000..11836ba + +Exit $fail diff --git a/tests/misc/sort-merge.pl b/tests/misc/sort-merge.pl -index 70d8af1..6b4840a 100755 +index 7eb4574..eda884c 100755 --- a/tests/misc/sort-merge.pl +++ b/tests/misc/sort-merge.pl @@ -26,6 +26,15 @@ my $prog = 'sort'; @@ -4931,7 +5073,7 @@ index 70d8af1..6b4840a 100755 my $verbose = $ENV{VERBOSE}; diff --git a/tests/misc/sort.pl b/tests/misc/sort.pl -index 86970ff..c016ff7 100755 +index 0b0adca..fd27821 100755 --- a/tests/misc/sort.pl +++ b/tests/misc/sort.pl @@ -24,10 +24,15 @@ my $prog = 'sort'; @@ -4999,7 +5141,7 @@ index 86970ff..c016ff7 100755 my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE}; diff --git a/tests/misc/unexpand.pl b/tests/misc/unexpand.pl -index 1c8e308..9f8ab89 100755 +index 2e1906f..fe66012 100755 --- a/tests/misc/unexpand.pl +++ b/tests/misc/unexpand.pl @@ -27,6 +27,14 @@ my $limits = getlimits (); @@ -5056,7 +5198,7 @@ index 1c8e308..9f8ab89 100755 my $verbose = $ENV{VERBOSE}; diff --git a/tests/misc/uniq.pl b/tests/misc/uniq.pl -index 74d3815..aae4c7e 100755 +index aa163cd..91d617d 100755 --- a/tests/misc/uniq.pl +++ b/tests/misc/uniq.pl @@ -23,9 +23,17 @@ my $limits = getlimits (); @@ -5132,7 +5274,7 @@ index 74d3815..aae4c7e 100755 @Tests = triple_test \@Tests; diff --git a/tests/pr/pr-tests.pl b/tests/pr/pr-tests.pl -index d0ac405..ff7d472 100755 +index 7ac6d4c..ae6cc35 100755 --- a/tests/pr/pr-tests.pl +++ b/tests/pr/pr-tests.pl @@ -24,6 +24,15 @@ use strict; @@ -5379,5 +5521,5 @@ index 0000000..8a82d74 +LC_ALL=C unexpand in in > out || fail=1 +compare exp out > /dev/null 2>&1 || fail=1 -- -2.31.1 +2.34.1 diff --git a/backport-dd-do-not-access-uninitialized.patch b/backport-dd-do-not-access-uninitialized.patch deleted file mode 100644 index b4860ba532ec44d4bf1a32170cfef3e5d5335b26..0000000000000000000000000000000000000000 --- a/backport-dd-do-not-access-uninitialized.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 604f8a6c4d58a646c8722fdf7cad9ee67479d8f7 Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Mon, 31 Jan 2022 10:20:21 -0800 -Subject: [PATCH] dd: do not access uninitialized -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -* src/dd.c (parse_integer): Avoid undefined behavior -that accesses an uninitialized ‘n’ when e == LONGINT_INVALID. -Return more-accurate error code when INTMAX_MAX < n. ---- - src/dd.c | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/src/dd.c b/src/dd.c -index e55f87f149..7360a49738 100644 ---- a/src/dd.c -+++ b/src/dd.c -@@ -1427,8 +1427,10 @@ static intmax_t - parse_integer (char const *str, strtol_error *invalid) - { - /* Call xstrtoumax, not xstrtoimax, since we don't want to -- allow strings like " -0". */ -- uintmax_t n; -+ allow strings like " -0". Initialize N to an interminate value; -+ calling code should not rely on this function returning 0 -+ when *INVALID represents a non-overflow error. */ -+ uintmax_t n = 0; - char *suffix; - strtol_error e = xstrtoumax (str, &suffix, 10, &n, "bcEGkKMPTwYZ0"); - -@@ -1468,7 +1470,7 @@ parse_integer (char const *str, strtol_error *invalid) - - if (INTMAX_MAX < n) - { -- *invalid = LONGINT_OVERFLOW; -+ *invalid = e | LONGINT_OVERFLOW; - return INTMAX_MAX; - } - diff --git a/backport-dd-improve-integer-overflow-checking.patch b/backport-dd-improve-integer-overflow-checking.patch deleted file mode 100644 index 3fc5f014fbf0d4de1596b331fd3f6ee86325fe70..0000000000000000000000000000000000000000 --- a/backport-dd-improve-integer-overflow-checking.patch +++ /dev/null @@ -1,833 +0,0 @@ -From e94d95075dd919e5e6ec0c8ed09477e58b863788 Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Tue, 18 Jan 2022 13:22:02 -0800 -Subject: [PATCH] dd: improve integer overflow checking -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -* src/dd.c: Prefer signed to unsigned types where either will do, -as this helps improve checking with gcc -fsanitize=undefined. -Limit the signed types to their intended ranges. -(MAX_BLOCKSIZE): Don’t exceed IDX_MAX - slop either. -(input_offset_overflow): Remove; overflow now denoted by negative. -(parse_integer): Return INTMAX_MAX on overflow, instead of unspecified. -Do not falsely report overflow for ‘00x99999999999999999999999999999’. -* tests/dd/misc.sh: New test for 00xBIG. -* tests/dd/skip-seek-past-file.sh: Adjust to new diagnostic wording. -New test for BIGxBIG. ---- - src/dd.c | 298 +++++++++++++++++--------------- - tests/dd/misc.sh | 9 +- - tests/dd/skip-seek-past-file.sh | 9 +- - 3 files changed, 177 insertions(+), 139 deletions(-) - -diff --git a/src/dd.c b/src/dd.c -index 35002f4d2e..bde92e97a4 100644 ---- a/src/dd.c -+++ b/src/dd.c -@@ -98,11 +98,12 @@ - #define OUTPUT_BLOCK_SLOP (page_size - 1) - - /* Maximum blocksize for the given SLOP. -- Keep it smaller than SIZE_MAX - SLOP, so that we can -+ Keep it smaller than MIN (IDX_MAX, SIZE_MAX) - SLOP, so that we can - allocate buffers that size. Keep it smaller than SSIZE_MAX, for - the benefit of system calls like "read". And keep it smaller than - OFF_T_MAX, for the benefit of the large-offset seek code. */ --#define MAX_BLOCKSIZE(slop) MIN (SIZE_MAX - (slop), MIN (SSIZE_MAX, OFF_T_MAX)) -+#define MAX_BLOCKSIZE(slop) MIN (MIN (IDX_MAX, SIZE_MAX) - (slop), \ -+ MIN (SSIZE_MAX, OFF_T_MAX)) - - /* Conversions bit masks. */ - enum -@@ -148,39 +149,39 @@ static char const *input_file = NULL; - static char const *output_file = NULL; - - /* The page size on this host. */ --static size_t page_size; -+static idx_t page_size; - - /* The number of bytes in which atomic reads are done. */ --static size_t input_blocksize = 0; -+static idx_t input_blocksize = 0; - - /* The number of bytes in which atomic writes are done. */ --static size_t output_blocksize = 0; -+static idx_t output_blocksize = 0; - - /* Conversion buffer size, in bytes. 0 prevents conversions. */ --static size_t conversion_blocksize = 0; -+static idx_t conversion_blocksize = 0; - - /* Skip this many records of 'input_blocksize' bytes before input. */ --static uintmax_t skip_records = 0; -+static intmax_t skip_records = 0; - - /* Skip this many bytes before input in addition of 'skip_records' - records. */ --static size_t skip_bytes = 0; -+static idx_t skip_bytes = 0; - - /* Skip this many records of 'output_blocksize' bytes before output. */ --static uintmax_t seek_records = 0; -+static intmax_t seek_records = 0; - - /* Skip this many bytes in addition to 'seek_records' records before - output. */ --static uintmax_t seek_bytes = 0; -+static intmax_t seek_bytes = 0; - - /* Whether the final output was done with a seek (rather than a write). */ - static bool final_op_was_seek; - - /* Copy only this many records. The default is effectively infinity. */ --static uintmax_t max_records = (uintmax_t) -1; -+static intmax_t max_records = INTMAX_MAX; - - /* Copy this many bytes in addition to 'max_records' records. */ --static size_t max_bytes = 0; -+static idx_t max_bytes = 0; - - /* Bit vector of conversions to apply. */ - static int conversions_mask = 0; -@@ -196,19 +197,19 @@ static int status_level = STATUS_DEFAULT; - static bool translation_needed = false; - - /* Number of partial blocks written. */ --static uintmax_t w_partial = 0; -+static intmax_t w_partial = 0; - - /* Number of full blocks written. */ --static uintmax_t w_full = 0; -+static intmax_t w_full = 0; - - /* Number of partial blocks read. */ --static uintmax_t r_partial = 0; -+static intmax_t r_partial = 0; - - /* Number of full blocks read. */ --static uintmax_t r_full = 0; -+static intmax_t r_full = 0; - - /* Number of bytes written. */ --static uintmax_t w_bytes = 0; -+static intmax_t w_bytes = 0; - - /* Time that dd started. */ - static xtime_t start_time; -@@ -226,16 +227,14 @@ static bool input_seekable; - If ESPIPE, do not issue any more diagnostics about it. */ - static int input_seek_errno; - --/* File offset of the input, in bytes, along with a flag recording -- whether it overflowed. */ --static uintmax_t input_offset; --static bool input_offset_overflow; -+/* File offset of the input, in bytes, or -1 if it overflowed. */ -+static off_t input_offset; - - /* True if a partial read should be diagnosed. */ - static bool warn_partial_read; - - /* Records truncated by conv=block. */ --static uintmax_t r_truncate = 0; -+static intmax_t r_truncate = 0; - - /* Output representation of newline and space characters. - They change if we're converting to EBCDIC. */ -@@ -253,10 +252,10 @@ static char *ibuf; - static char *obuf; - - /* Current index into 'obuf'. */ --static size_t oc = 0; -+static idx_t oc = 0; - - /* Index into current line, for 'conv=block' and 'conv=unblock'. */ --static size_t col = 0; -+static idx_t col = 0; - - /* The set of signals that are caught. */ - static sigset_t caught_signals; -@@ -274,7 +273,7 @@ static bool i_nocache, o_nocache; - static bool i_nocache_eof, o_nocache_eof; - - /* Function used for read (to handle iflag=fullblock parameter). */ --static ssize_t (*iread_fnc) (int fd, char *buf, size_t size); -+static ssize_t (*iread_fnc) (int fd, char *buf, idx_t size); - - /* A longest symbol in the struct symbol_values tables below. */ - #define LONGEST_SYMBOL "count_bytes" -@@ -701,11 +700,10 @@ alloc_ibuf (void) - char *buf = malloc (input_blocksize + INPUT_BLOCK_SLOP); - if (!buf) - { -- uintmax_t ibs = input_blocksize; - char hbuf[LONGEST_HUMAN_READABLE + 1]; - die (EXIT_FAILURE, 0, -- _("memory exhausted by input buffer of size %"PRIuMAX" bytes (%s)"), -- ibs, -+ _("memory exhausted by input buffer of size %td bytes (%s)"), -+ input_blocksize, - human_readable (input_blocksize, hbuf, - human_opts | human_base_1024, 1, 1)); - } -@@ -729,12 +727,11 @@ alloc_obuf (void) - char *buf = malloc (output_blocksize + OUTPUT_BLOCK_SLOP); - if (!buf) - { -- uintmax_t obs = output_blocksize; - char hbuf[LONGEST_HUMAN_READABLE + 1]; - die (EXIT_FAILURE, 0, -- _("memory exhausted by output buffer of size %"PRIuMAX -+ _("memory exhausted by output buffer of size %td" - " bytes (%s)"), -- obs, -+ output_blocksize, - human_readable (output_blocksize, hbuf, - human_opts | human_base_1024, 1, 1)); - } -@@ -793,8 +790,7 @@ print_xfer_stats (xtime_t progress_time) - if (start_time < now) - { - double XTIME_PRECISIONe0 = XTIME_PRECISION; -- uintmax_t delta_xtime = now; -- delta_xtime -= start_time; -+ xtime_t delta_xtime = now - start_time; - delta_s = delta_xtime / XTIME_PRECISIONe0; - bytes_per_second = human_readable (w_bytes, bpsbuf, human_opts, - XTIME_PRECISION, delta_xtime); -@@ -822,16 +818,16 @@ print_xfer_stats (xtime_t progress_time) - int stats_len - = (abbreviation_lacks_prefix (si) - ? fprintf (stderr, -- ngettext ("%"PRIuMAX" byte copied, %s, %s", -- "%"PRIuMAX" bytes copied, %s, %s", -+ ngettext ("%"PRIdMAX" byte copied, %s, %s", -+ "%"PRIdMAX" bytes copied, %s, %s", - select_plural (w_bytes)), - w_bytes, delta_s_buf, bytes_per_second) - : abbreviation_lacks_prefix (iec) - ? fprintf (stderr, -- _("%"PRIuMAX" bytes (%s) copied, %s, %s"), -+ _("%"PRIdMAX" bytes (%s) copied, %s, %s"), - w_bytes, si, delta_s_buf, bytes_per_second) - : fprintf (stderr, -- _("%"PRIuMAX" bytes (%s, %s) copied, %s, %s"), -+ _("%"PRIdMAX" bytes (%s, %s) copied, %s, %s"), - w_bytes, si, iec, delta_s_buf, bytes_per_second)); - - if (progress_time) -@@ -863,14 +859,14 @@ print_stats (void) - } - - fprintf (stderr, -- _("%"PRIuMAX"+%"PRIuMAX" records in\n" -- "%"PRIuMAX"+%"PRIuMAX" records out\n"), -+ _("%"PRIdMAX"+%"PRIdMAX" records in\n" -+ "%"PRIdMAX"+%"PRIdMAX" records out\n"), - r_full, r_partial, w_full, w_partial); - - if (r_truncate != 0) - fprintf (stderr, -- ngettext ("%"PRIuMAX" truncated record\n", -- "%"PRIuMAX" truncated records\n", -+ ngettext ("%"PRIdMAX" truncated record\n", -+ "%"PRIdMAX" truncated records\n", - select_plural (r_truncate)), - r_truncate); - -@@ -1050,7 +1046,9 @@ cache_round (int fd, off_t len) - - if (len) - { -- uintmax_t c_pending = *pending + len; -+ intmax_t c_pending; -+ if (INT_ADD_WRAPV (*pending, len, &c_pending)) -+ c_pending = INTMAX_MAX; - *pending = c_pending % IO_BUFSIZE; - if (c_pending > *pending) - len = c_pending - *pending; -@@ -1138,7 +1136,7 @@ invalidate_cache (int fd, off_t len) - bytes read if successful, -1 (setting errno) on failure. */ - - static ssize_t --iread (int fd, char *buf, size_t size) -+iread (int fd, char *buf, idx_t size) - { - ssize_t nread; - static ssize_t prev_nread; -@@ -1167,11 +1165,11 @@ iread (int fd, char *buf, size_t size) - { - if (0 < prev_nread && prev_nread < size) - { -- uintmax_t prev = prev_nread; -+ idx_t prev = prev_nread; - if (status_level != STATUS_NONE) -- error (0, 0, ngettext (("warning: partial read (%"PRIuMAX" byte); " -+ error (0, 0, ngettext (("warning: partial read (%td byte); " - "suggest iflag=fullblock"), -- ("warning: partial read (%"PRIuMAX" bytes); " -+ ("warning: partial read (%td bytes); " - "suggest iflag=fullblock"), - select_plural (prev)), - prev); -@@ -1185,7 +1183,7 @@ iread (int fd, char *buf, size_t size) - - /* Wrapper around iread function to accumulate full blocks. */ - static ssize_t --iread_fullblock (int fd, char *buf, size_t size) -+iread_fullblock (int fd, char *buf, idx_t size) - { - ssize_t nread = 0; - -@@ -1209,10 +1207,10 @@ iread_fullblock (int fd, char *buf, size_t size) - this is less than SIZE. Keep trying if there are partial - writes. */ - --static size_t --iwrite (int fd, char const *buf, size_t size) -+static idx_t -+iwrite (int fd, char const *buf, idx_t size) - { -- size_t total_written = 0; -+ idx_t total_written = 0; - - if ((output_flags & O_DIRECT) && size < output_blocksize) - { -@@ -1290,7 +1288,7 @@ iwrite (int fd, char const *buf, size_t size) - static void - write_output (void) - { -- size_t nwritten = iwrite (STDOUT_FILENO, obuf, output_blocksize); -+ idx_t nwritten = iwrite (STDOUT_FILENO, obuf, output_blocksize); - w_bytes += nwritten; - if (nwritten != output_blocksize) - { -@@ -1422,7 +1420,7 @@ parse_symbols (char const *str, struct symbol_value const *table, - { - if (! entry->symbol[0]) - { -- size_t slen = strcomma ? strcomma - str : strlen (str); -+ idx_t slen = strcomma ? strcomma - str : strlen (str); - error (0, 0, "%s: %s", _(error_msgid), - quotearg_n_style_mem (0, locale_quoting_style, str, slen)); - usage (EXIT_FAILURE); -@@ -1443,40 +1441,61 @@ parse_symbols (char const *str, struct symbol_value const *table, - - /* Return the value of STR, interpreted as a non-negative decimal integer, - optionally multiplied by various values. -- Set *INVALID to a nonzero error value if STR does not represent a -- number in this format. */ -+ If STR does not represent a number in this format, -+ set *INVALID to a nonzero error value and return -+ INTMAX_MAX if it is an overflow, an indeterminate value otherwise. */ - --static uintmax_t -+static intmax_t - parse_integer (char const *str, strtol_error *invalid) - { -+ /* Call xstrtoumax, not xstrtoimax, since we don't want to -+ allow strings like " -0". */ - uintmax_t n; - char *suffix; - strtol_error e = xstrtoumax (str, &suffix, 10, &n, "bcEGkKMPTwYZ0"); - -- if (e == LONGINT_INVALID_SUFFIX_CHAR && *suffix == 'x') -+ if ((e & ~LONGINT_OVERFLOW) == LONGINT_INVALID_SUFFIX_CHAR -+ && *suffix == 'x') - { -- uintmax_t multiplier = parse_integer (suffix + 1, invalid); -+ strtol_error invalid2 = LONGINT_OK; -+ intmax_t result = parse_integer (suffix + 1, &invalid2); -+ if ((invalid2 & ~LONGINT_OVERFLOW) != LONGINT_OK) -+ { -+ *invalid = invalid2; -+ return result; -+ } - -- if (multiplier != 0 && n * multiplier / multiplier != n) -+ if (INT_MULTIPLY_WRAPV (n, result, &result)) - { - *invalid = LONGINT_OVERFLOW; -- return 0; -+ return INTMAX_MAX; - } - -- if (n == 0 && STRPREFIX (str, "0x")) -- error (0, 0, -- _("warning: %s is a zero multiplier; " -- "use %s if that is intended"), -- quote_n (0, "0x"), quote_n (1, "00x")); -+ if (result == 0) -+ { -+ if (STRPREFIX (str, "0x")) -+ error (0, 0, -+ _("warning: %s is a zero multiplier; " -+ "use %s if that is intended"), -+ quote_n (0, "0x"), quote_n (1, "00x")); -+ } -+ else if ((e | invalid2) & LONGINT_OVERFLOW) -+ { -+ *invalid = LONGINT_OVERFLOW; -+ return INTMAX_MAX; -+ } - -- n *= multiplier; -+ return result; - } -- else if (e != LONGINT_OK) -+ -+ if (INTMAX_MAX < n) - { -- *invalid = e; -- return 0; -+ *invalid = LONGINT_OVERFLOW; -+ return INTMAX_MAX; - } - -+ if (e != LONGINT_OK) -+ *invalid = e; - return n; - } - -@@ -1492,10 +1511,10 @@ operand_is (char const *operand, char const *name) - static void - scanargs (int argc, char *const *argv) - { -- size_t blocksize = 0; -- uintmax_t count = (uintmax_t) -1; -- uintmax_t skip = 0; -- uintmax_t seek = 0; -+ idx_t blocksize = 0; -+ intmax_t count = INTMAX_MAX; -+ intmax_t skip = 0; -+ intmax_t seek = 0; - - for (int i = optind; i < argc; i++) - { -@@ -1529,33 +1548,34 @@ scanargs (int argc, char *const *argv) - else - { - strtol_error invalid = LONGINT_OK; -- uintmax_t n = parse_integer (val, &invalid); -- uintmax_t n_min = 0; -- uintmax_t n_max = UINTMAX_MAX; -+ intmax_t n = parse_integer (val, &invalid); -+ intmax_t n_min = 0; -+ intmax_t n_max = INTMAX_MAX; -+ idx_t *converted_idx = NULL; - - if (operand_is (name, "ibs")) - { - n_min = 1; - n_max = MAX_BLOCKSIZE (INPUT_BLOCK_SLOP); -- input_blocksize = n; -+ converted_idx = &input_blocksize; - } - else if (operand_is (name, "obs")) - { - n_min = 1; - n_max = MAX_BLOCKSIZE (OUTPUT_BLOCK_SLOP); -- output_blocksize = n; -+ converted_idx = &output_blocksize; - } - else if (operand_is (name, "bs")) - { - n_min = 1; - n_max = MAX_BLOCKSIZE (INPUT_BLOCK_SLOP); -- blocksize = n; -+ converted_idx = &blocksize; - } - else if (operand_is (name, "cbs")) - { - n_min = 1; -- n_max = SIZE_MAX; -- conversion_blocksize = n; -+ n_max = MIN (SIZE_MAX, IDX_MAX); -+ converted_idx = &conversion_blocksize; - } - else if (operand_is (name, "skip")) - skip = n; -@@ -1578,6 +1598,8 @@ scanargs (int argc, char *const *argv) - if (invalid != LONGINT_OK) - die (EXIT_FAILURE, invalid == LONGINT_OVERFLOW ? EOVERFLOW : 0, - "%s: %s", _("invalid number"), quote (val)); -+ else if (converted_idx) -+ *converted_idx = n; - } - } - -@@ -1628,12 +1650,12 @@ scanargs (int argc, char *const *argv) - else if (skip != 0) - skip_records = skip; - -- if (input_flags & O_COUNT_BYTES && count != (uintmax_t) -1) -+ if (input_flags & O_COUNT_BYTES && count != INTMAX_MAX) - { - max_records = count / input_blocksize; - max_bytes = count % input_blocksize; - } -- else if (count != (uintmax_t) -1) -+ else if (count != INTMAX_MAX) - max_records = count; - - if (output_flags & O_SEEK_BYTES && seek != 0) -@@ -1651,7 +1673,7 @@ scanargs (int argc, char *const *argv) - warn_partial_read = - (! (conversions_mask & C_TWOBUFS) && ! (input_flags & O_FULLBLOCK) - && (skip_records -- || (0 < max_records && max_records < (uintmax_t) -1) -+ || (0 < max_records && max_records < INTMAX_MAX) - || (input_flags | output_flags) & O_DIRECT)); - - iread_fnc = ((input_flags & O_FULLBLOCK) -@@ -1726,9 +1748,9 @@ apply_translations (void) - to the NREAD bytes in BUF. */ - - static void --translate_buffer (char *buf, size_t nread) -+translate_buffer (char *buf, idx_t nread) - { -- size_t i; -+ idx_t i; - char *cp; - for (i = nread, cp = buf; i; i--, cp++) - *cp = trans_table[to_uchar (*cp)]; -@@ -1746,7 +1768,7 @@ static char saved_char; - next call. Return the new start of the BUF buffer. */ - - static char * --swab_buffer (char *buf, size_t *nread) -+swab_buffer (char *buf, idx_t *nread) - { - char *bufstart = buf; - -@@ -1770,7 +1792,7 @@ swab_buffer (char *buf, size_t *nread) - toward the beginning. This way we only move half of the data. */ - - char *cp = bufstart + *nread; /* Start one char past the last. */ -- for (size_t i = *nread / 2; i; i--, cp -= 2) -+ for (idx_t i = *nread >> 1; i; i--, cp -= 2) - *cp = *(cp - 2); - - return ++bufstart; -@@ -1780,11 +1802,10 @@ swab_buffer (char *buf, size_t *nread) - necessary. */ - - static void --advance_input_offset (uintmax_t offset) -+advance_input_offset (intmax_t offset) - { -- input_offset += offset; -- if (input_offset < offset) -- input_offset_overflow = true; -+ if (0 <= input_offset && INT_ADD_WRAPV (input_offset, offset, &input_offset)) -+ input_offset = -1; - } - - /* Throw away RECORDS blocks of BLOCKSIZE bytes plus BYTES bytes on -@@ -1796,18 +1817,18 @@ advance_input_offset (uintmax_t offset) - reached. If FDESC is STDOUT_FILENO, on return, BYTES is the - remaining bytes in addition to the remaining records. */ - --static uintmax_t --skip (int fdesc, char const *file, uintmax_t records, size_t blocksize, -- size_t *bytes) -+static intmax_t -+skip (int fdesc, char const *file, intmax_t records, idx_t blocksize, -+ idx_t *bytes) - { -- uintmax_t offset = records * blocksize + *bytes; -- - /* Try lseek and if an error indicates it was an inappropriate operation -- - or if the file offset is not representable as an off_t -- - fall back on using read. */ - - errno = 0; -- if (records <= OFF_T_MAX / blocksize -+ off_t offset; -+ if (! INT_MULTIPLY_WRAPV (records, blocksize, &offset) -+ && ! INT_ADD_WRAPV (offset, *bytes, &offset) - && 0 <= lseek (fdesc, offset, SEEK_CUR)) - { - if (fdesc == STDIN_FILENO) -@@ -1815,7 +1836,8 @@ skip (int fdesc, char const *file, uintmax_t records, size_t blocksize, - struct stat st; - if (ifstat (STDIN_FILENO, &st) != 0) - die (EXIT_FAILURE, errno, _("cannot fstat %s"), quoteaf (file)); -- if (usable_st_size (&st) && st.st_size < input_offset + offset) -+ if (usable_st_size (&st) && 0 <= input_offset -+ && st.st_size - input_offset < offset) - { - /* When skipping past EOF, return the number of _full_ blocks - * that are not skipped, and set offset to EOF, so the caller -@@ -1920,7 +1942,7 @@ skip (int fdesc, char const *file, uintmax_t records, size_t blocksize, - be seekable. */ - - static bool --advance_input_after_read_error (size_t nbytes) -+advance_input_after_read_error (idx_t nbytes) - { - if (! input_seekable) - { -@@ -1932,8 +1954,7 @@ advance_input_after_read_error (size_t nbytes) - { - off_t offset; - advance_input_offset (nbytes); -- input_offset_overflow |= (OFF_T_MAX < input_offset); -- if (input_offset_overflow) -+ if (input_offset < 0) - { - error (0, 0, _("offset overflow while reading file %s"), - quoteaf (input_file)); -@@ -1962,13 +1983,13 @@ advance_input_after_read_error (size_t nbytes) - /* Copy NREAD bytes of BUF, with no conversions. */ - - static void --copy_simple (char const *buf, size_t nread) -+copy_simple (char const *buf, idx_t nread) - { - char const *start = buf; /* First uncopied char in BUF. */ - - do - { -- size_t nfree = MIN (nread, output_blocksize - oc); -+ idx_t nfree = MIN (nread, output_blocksize - oc); - - memcpy (obuf + oc, start, nfree); - -@@ -1986,15 +2007,15 @@ copy_simple (char const *buf, size_t nread) - replacing the newline with trailing spaces). */ - - static void --copy_with_block (char const *buf, size_t nread) -+copy_with_block (char const *buf, idx_t nread) - { -- for (size_t i = nread; i; i--, buf++) -+ for (idx_t i = nread; i; i--, buf++) - { - if (*buf == newline_character) - { - if (col < conversion_blocksize) - { -- size_t j; -+ idx_t j; - for (j = col; j < conversion_blocksize; j++) - output_char (space_character); - } -@@ -2016,11 +2037,11 @@ copy_with_block (char const *buf, size_t nread) - with a newline). */ - - static void --copy_with_unblock (char const *buf, size_t nread) -+copy_with_unblock (char const *buf, idx_t nread) - { -- static size_t pending_spaces = 0; -+ static idx_t pending_spaces = 0; - -- for (size_t i = 0; i < nread; i++) -+ for (idx_t i = 0; i < nread; i++) - { - char c = buf[i]; - -@@ -2104,10 +2125,10 @@ dd_copy (void) - - /* If nonzero, then the previously read block was partial and - PARTREAD was its size. */ -- size_t partread = 0; -+ idx_t partread = 0; - - int exit_status = EXIT_SUCCESS; -- size_t n_bytes_read; -+ idx_t n_bytes_read; - - /* Leave at least one extra byte at the beginning and end of 'ibuf' - for conv=swab, but keep the buffer address even. But some peculiar -@@ -2128,11 +2149,13 @@ dd_copy (void) - - if (skip_records != 0 || skip_bytes != 0) - { -- uintmax_t us_bytes = input_offset + (skip_records * input_blocksize) -- + skip_bytes; -- uintmax_t us_blocks = skip (STDIN_FILENO, input_file, -- skip_records, input_blocksize, &skip_bytes); -- us_bytes -= input_offset; -+ intmax_t us_bytes; -+ bool us_bytes_overflow = -+ (INT_MULTIPLY_WRAPV (skip_records, input_blocksize, &us_bytes) -+ || INT_ADD_WRAPV (skip_bytes, us_bytes, &us_bytes)); -+ off_t input_offset0 = input_offset; -+ intmax_t us_blocks = skip (STDIN_FILENO, input_file, -+ skip_records, input_blocksize, &skip_bytes); - - /* POSIX doesn't say what to do when dd detects it has been - asked to skip past EOF, so I assume it's non-fatal. -@@ -2140,7 +2163,10 @@ dd_copy (void) - 1. file is too small - 2. pipe has not enough data - 3. partial reads */ -- if ((us_blocks || (!input_offset_overflow && us_bytes)) -+ if ((us_blocks -+ || (0 <= input_offset -+ && (us_bytes_overflow -+ || us_bytes != input_offset - input_offset0))) - && status_level != STATUS_NONE) - { - error (0, 0, -@@ -2150,8 +2176,8 @@ dd_copy (void) - - if (seek_records != 0 || seek_bytes != 0) - { -- size_t bytes = seek_bytes; -- uintmax_t write_records = skip (STDOUT_FILENO, output_file, -+ idx_t bytes = seek_bytes; -+ intmax_t write_records = skip (STDOUT_FILENO, output_file, - seek_records, output_blocksize, &bytes); - - if (write_records != 0 || bytes != 0) -@@ -2160,7 +2186,7 @@ dd_copy (void) - - do - { -- size_t size = write_records ? output_blocksize : bytes; -+ idx_t size = write_records ? output_blocksize : bytes; - if (iwrite (STDOUT_FILENO, obuf, size) != size) - { - error (0, errno, _("writing to %s"), quoteaf (output_file)); -@@ -2230,7 +2256,7 @@ dd_copy (void) - if (conversions_mask & C_NOERROR) - { - print_stats (); -- size_t bad_portion = input_blocksize - partread; -+ idx_t bad_portion = input_blocksize - partread; - - /* We already know this data is not cached, - but call this so that correct offsets are maintained. */ -@@ -2284,7 +2310,7 @@ dd_copy (void) - - if (ibuf == obuf) /* If not C_TWOBUFS. */ - { -- size_t nwritten = iwrite (STDOUT_FILENO, obuf, n_bytes_read); -+ idx_t nwritten = iwrite (STDOUT_FILENO, obuf, n_bytes_read); - w_bytes += nwritten; - if (nwritten != n_bytes_read) - { -@@ -2331,7 +2357,7 @@ dd_copy (void) - { - /* If the final input line didn't end with a '\n', pad - the output block to 'conversion_blocksize' chars. */ -- for (size_t i = col; i < conversion_blocksize; i++) -+ for (idx_t i = col; i < conversion_blocksize; i++) - output_char (space_character); - } - -@@ -2344,7 +2370,7 @@ dd_copy (void) - /* Write out the last block. */ - if (oc != 0) - { -- size_t nwritten = iwrite (STDOUT_FILENO, obuf, oc); -+ idx_t nwritten = iwrite (STDOUT_FILENO, obuf, oc); - w_bytes += nwritten; - if (nwritten != 0) - w_partial++; -@@ -2477,15 +2503,14 @@ main (int argc, char **argv) - - if (seek_records != 0 && !(conversions_mask & C_NOTRUNC)) - { -- uintmax_t size = seek_records * output_blocksize + seek_bytes; -- unsigned long int obs = output_blocksize; -- -- if (OFF_T_MAX / output_blocksize < seek_records) -+ off_t size; -+ if (INT_MULTIPLY_WRAPV (seek_records, output_blocksize, &size) -+ || INT_ADD_WRAPV (seek_bytes, size, &size)) - die (EXIT_FAILURE, 0, - _("offset too large: " -- "cannot truncate to a length of seek=%"PRIuMAX"" -- " (%lu-byte) blocks"), -- seek_records, obs); -+ "cannot truncate to a length of seek=%"PRIdMAX"" -+ " (%td-byte) blocks"), -+ seek_records, output_blocksize); - - if (iftruncate (STDOUT_FILENO, size) != 0) - { -@@ -2502,10 +2527,13 @@ main (int argc, char **argv) - if (S_ISREG (stdout_stat.st_mode) - || S_ISDIR (stdout_stat.st_mode) - || S_TYPEISSHM (&stdout_stat)) -- die (EXIT_FAILURE, ftruncate_errno, -- _("failed to truncate to %"PRIuMAX" bytes" -- " in output file %s"), -- size, quoteaf (output_file)); -+ { -+ intmax_t isize = size; -+ die (EXIT_FAILURE, ftruncate_errno, -+ _("failed to truncate to %"PRIdMAX" bytes" -+ " in output file %s"), -+ isize, quoteaf (output_file)); -+ } - } - } - } -diff --git a/tests/dd/misc.sh b/tests/dd/misc.sh -index 6ca54faac3..d20cbacc87 100755 ---- a/tests/dd/misc.sh -+++ b/tests/dd/misc.sh -@@ -19,6 +19,7 @@ - - . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src - print_ver_ dd -+export LC_ALL=C - - tmp_in=dd-in - tmp_in2=dd-in2 -@@ -98,7 +99,7 @@ test "$outbytes" -eq 3 || fail=1 - # A delay is required to trigger a failure. - # There might be some missed failures but it's unlikely. - (echo a; sleep .1; echo b) \ -- | env LC_ALL=C dd bs=4 status=noxfer iflag=fullblock >out 2>err || fail=1 -+ | dd bs=4 status=noxfer iflag=fullblock >out 2>err || fail=1 - printf 'a\nb\n' > out_ok || framework_failure_ - echo "1+0 records in - 1+0 records out" > err_ok || framework_failure_ -@@ -116,5 +117,11 @@ dd: warning: '0x' is a zero multiplier; use '00x' if that is intended - EOF - compare exp err || fail=1 - -+echo "0+0 records in -+0+0 records out" >err_ok || framework_failure_ -+big=9999999999999999999999999999999999999999999999999999999999999 -+dd if=$tmp_in of=$tmp_out count=00x$big status=noxfer 2>err || fail=1 -+compare /dev/null $tmp_out || fail=1 -+compare err_ok err || fail=1 - - Exit $fail -diff --git a/tests/dd/skip-seek-past-file.sh b/tests/dd/skip-seek-past-file.sh -index 7c2baa2e1a..e952448e2b 100755 ---- a/tests/dd/skip-seek-past-file.sh -+++ b/tests/dd/skip-seek-past-file.sh -@@ -20,7 +20,7 @@ - print_ver_ dd - require_sparse_support_ # for 'truncate --size=$OFF_T_MAX' - eval $(getlimits) # for OFF_T limits -- -+export LC_ALL=C - - printf "1234" > file || framework_failure_ - -@@ -65,8 +65,11 @@ compare err_ok err || fail=1 - - # skipping > OFF_T_MAX should fail immediately - dd bs=1 skip=$OFF_T_OFLOW count=0 status=noxfer < file 2> err && fail=1 --# error message should be "... cannot skip: strerror(EOVERFLOW)" --grep "cannot skip:" err >/dev/null || fail=1 -+# error message should be "... invalid number: strerror(EOVERFLOW)" -+grep "invalid number:" err >/dev/null || fail=1 -+dd bs=1 skip=${OFF_T_OFLOW}x$OFF_T_OFLOW count=0 status=noxfer < file 2> err && -+ fail=1 -+grep "invalid number:" err >/dev/null || fail=1 - - # skipping > max file size should fail immediately - if ! truncate --size=$OFF_T_MAX in 2>/dev/null; then diff --git a/backport-df-fix-memory-leak.patch b/backport-df-fix-memory-leak.patch deleted file mode 100644 index 83a43b67724e25b021507759a6c5d5f3c23c7736..0000000000000000000000000000000000000000 --- a/backport-df-fix-memory-leak.patch +++ /dev/null @@ -1,51 +0,0 @@ -From fb7579768d688a300c4ac76451e1fc7cad59e3e8 Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Mon, 31 Jan 2022 19:52:43 -0800 -Subject: [PATCH] df: fix memory leak - -* src/df.c (devlist_free): Remove. -(filter_mount_list): Free all of devlist, instead of merely -the entries in devlist_table. ---- - src/df.c | 14 ++++---------- - 1 file changed, 4 insertions(+), 10 deletions(-) - -diff --git a/src/df.c b/src/df.c -index 7d32078071..4b2cfb77a6 100644 ---- a/src/df.c -+++ b/src/df.c -@@ -710,12 +710,6 @@ devlist_for_dev (dev_t dev) - return found->seen_last; - } - --static void --devlist_free (void *p) --{ -- free (p); --} -- - /* Filter mount list by skipping duplicate entries. - In the case of duplicates - based on the device number - the mount entry - with a '/' in its me_devname (i.e., not pseudo name like tmpfs) wins. -@@ -736,9 +730,7 @@ filter_mount_list (bool devices_only) - mount_list_size++; - - devlist_table = hash_initialize (mount_list_size, NULL, -- devlist_hash, -- devlist_compare, -- devlist_free); -+ devlist_hash, devlist_compare, NULL); - if (devlist_table == NULL) - xalloc_die (); - -@@ -845,7 +837,9 @@ filter_mount_list (bool devices_only) - me = device_list->me; - me->me_next = mount_list; - mount_list = me; -- device_list = device_list->next; -+ struct devlist *next = device_list->next; -+ free (device_list); -+ device_list = next; - } - - hash_free (devlist_table); diff --git a/backport-fts-fail-gracefully-when-out-of-memory.patch b/backport-fts-fail-gracefully-when-out-of-memory.patch deleted file mode 100644 index a28f48e6eb0bb543dd38e38550565059347085ae..0000000000000000000000000000000000000000 --- a/backport-fts-fail-gracefully-when-out-of-memory.patch +++ /dev/null @@ -1,50 +0,0 @@ -From f17d397771164c1b0f77fea8fb0abdc99cf4a3e1 Mon Sep 17 00:00:00 2001 -From: ChuanGang Jiang -Date: Mon, 27 Feb 2023 11:46:12 +0000 -Subject: [PATCH] fts: fail gracefully when out of memory - -* lib/fts.c (fts_read): Set errno==ENOMEM and return NULL -when setup_dir() fails, rather than hitting an assertion later. - -Refernece:https://github.com/coreutils/gnulib/commit/f17d397771164c1b0f77fea8fb0abdc99cf4a3e1 -Conflict:ChangeLog context adaptation - ---- - ChangeLog | 6 ++++++ - lib/fts.c | 6 +++++- - 2 files changed, 11 insertions(+), 1 deletion(-) - -diff --git a/ChangeLog b/ChangeLog -index 1785234..43b0afa 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,9 @@ -+2023-02-27 ChuanGang Jiang -+ -+ fts: fail gracefully when out of memory -+ * lib/fts.c (fts_read): Set errno==ENOMEM and return NULL -+ when setup_dir() fails, rather than hitting an assertion later. -+ - 2022-12-06 Paul Eggert - - fts: fix race + mishandling of fstatat failure -diff --git a/lib/fts.c b/lib/fts.c -index 78584b2902..794a4f75d7 100644 ---- a/lib/fts.c -+++ b/lib/fts.c -@@ -979,7 +979,11 @@ next: tmp = p; - } - free_dir(sp); - fts_load(sp, p); -- setup_dir(sp); -+ if (! setup_dir(sp)) { -+ free_dir(sp); -+ __set_errno (ENOMEM); -+ return (NULL); -+ } - goto check_for_dir; - } - --- -2.27.0 - diff --git a/backport-fts-fix-race-mishandling-of-fstatat-failure.patch b/backport-fts-fix-race-mishandling-of-fstatat-failure.patch deleted file mode 100644 index 841bae4fe9fa0ec032719596f718e2b8d450cdcd..0000000000000000000000000000000000000000 --- a/backport-fts-fix-race-mishandling-of-fstatat-failure.patch +++ /dev/null @@ -1,96 +0,0 @@ -From 440b528b1d81dd31b2a2e4dde20d5c837c147811 Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Tue, 6 Dec 2022 10:27:43 -0800 -Subject: [PATCH] fts: fix race + mishandling of fstatat failure -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -I hope this fixes a Luke Dashjr coreutils bug report about ext4 -ramdisks; see “9.1: du Aborted (corrupt filesystem)” -. -* lib/fts.c (fts_build): Fix two bugs. First, fts_stat was being -called without checking its return value, causing a later abort. -Second, there was a race between opening a directory and statting -it, fixed by using fstat on the file descriptor rather than -fstatat on the directory name. - -Reference:https://github.com/coretuils/gnulib/commit/440b528b1d81dd31b2a2e4dde20d5c837c147811 -Conflict:Context adapation - ---- - ChangeLog | 10 ++++++++++ - lib/fts.c | 32 ++++++++++++++++++++++++-------- - 2 files changed, 34 insertions(+), 8 deletions(-) - -diff --git a/ChangeLog b/ChangeLog -index 44fe270..1785234 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,15 @@ -+2022-12-06 Paul Eggert -+ -+ fts: fix race + mishandling of fstatat failure -+ I hope this fixes a Luke Dashjr coreutils bug report about ext4 -+ ramdisks; see “9.1: du Aborted (corrupt filesystem)” -+ . -+ * lib/fts.c (fts_build): Fix two bugs. First, fts_stat was being -+ called without checking its return value, causing a later abort. -+ Second, there was a race between opening a directory and statting -+ it, fixed by using fstat on the file descriptor rather than -+ fstatat on the directory name. -+ - 2021-09-24 Pádraig Brady - - version 9.0 -diff --git a/lib/fts.c b/lib/fts.c -index 27354d39c8..74a08f7ec8 100644 ---- a/lib/fts.c -+++ b/lib/fts.c -@@ -1316,19 +1316,35 @@ fts_build (register FTS *sp, int type) - /* Rather than calling fts_stat for each and every entry encountered - in the readdir loop (below), stat each directory only right after - opening it. */ -- if (cur->fts_info == FTS_NSOK) -- cur->fts_info = fts_stat(sp, cur, false); -- else if (sp->fts_options & FTS_TIGHT_CYCLE_CHECK) -- { -- /* Now read the stat info again after opening a directory to -+ bool stat_optimization = cur->fts_info == FTS_NSOK; -+ -+ if (stat_optimization -+ /* Also read the stat info again after opening a directory to - reveal eventual changes caused by a submount triggered by - the traversal. But do it only for utilities which use - FTS_TIGHT_CYCLE_CHECK. Therefore, only find and du - benefit/suffer from this feature for now. */ -- LEAVE_DIR (sp, cur, "4"); -- fts_stat (sp, cur, false); -- if (! enter_dir (sp, cur)) -+ || ISSET (FTS_TIGHT_CYCLE_CHECK)) -+ { -+ if (!stat_optimization) -+ LEAVE_DIR (sp, cur, "4"); -+ if (fstat (dir_fd, cur->fts_statp) != 0) -+ { -+ int fstat_errno = errno; -+ closedir_and_clear (cur->fts_dirp); -+ if (type == BREAD) -+ { -+ cur->fts_errno = fstat_errno; -+ cur->fts_info = FTS_NS; -+ } -+ __set_errno (fstat_errno); -+ return NULL; -+ } -+ if (stat_optimization) -+ cur->fts_info = FTS_D; -+ else if (! enter_dir (sp, cur)) - { -+ closedir_and_clear (cur->fts_dirp); - __set_errno (ENOMEM); - return NULL; - } --- -2.27.0 - diff --git a/backport-ls-avoid-triggering-automounts.patch b/backport-ls-avoid-triggering-automounts.patch deleted file mode 100644 index 3a7bbbfba786dbb9aa46e1a07bcc520dd41a67f0..0000000000000000000000000000000000000000 --- a/backport-ls-avoid-triggering-automounts.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 85c975df2c25bd799370b04bb294e568e001102f Mon Sep 17 00:00:00 2001 -From: Rohan Sable -Date: Mon, 7 Mar 2022 14:14:13 +0000 -Subject: [PATCH] ls: avoid triggering automounts - -statx() has different defaults wrt automounting -compared to stat() or lstat(), so explicitly -set the AT_NO_AUTOMOUNT flag to suppress that behavior, -and avoid unintended operations or potential errors. - -* src/ls.c (do_statx): Pass AT_NO_AUTOMOUNT to avoid this behavior. -* NEWS: Mention the change in behavior. -Fixes https://bugs.gnu.org/54286 - -Signed-off-by: Rohan Sable ---- - src/ls.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/ls.c b/src/ls.c -index 1930e4abbc..255789061b 100644 ---- a/src/ls.c -+++ b/src/ls.c -@@ -1177,7 +1177,7 @@ do_statx (int fd, char const *name, struct stat *st, int flags, - { - struct statx stx; - bool want_btime = mask & STATX_BTIME; -- int ret = statx (fd, name, flags, mask, &stx); -+ int ret = statx (fd, name, flags | AT_NO_AUTOMOUNT, mask, &stx); - if (ret >= 0) - { - statx_to_stat (&stx, st); diff --git a/backport-pr-fix-infinite-loop-when-double-spacing.patch b/backport-pr-fix-infinite-loop-when-double-spacing.patch index 8fd90d5323fa11751d4576dd696ecf9411a9a63a..50f8829f5a77029604a92afe0568d75fe47e7b59 100644 --- a/backport-pr-fix-infinite-loop-when-double-spacing.patch +++ b/backport-pr-fix-infinite-loop-when-double-spacing.patch @@ -25,15 +25,16 @@ index f65eb95..5320b9c 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,9 @@ GNU coreutils NEWS -*- outline -*- - * Noteworthy changes in release 9.0 (2021-09-24) [stable] + * Noteworthy changes in release 9.3 (2023-04-18) [stable] ** Bug fixes ++ + 'pr --length=1 --double-space' no longer enters an infinite loop. + [This bug was present in "the beginning".] -+ - tail --follow=name works again with non seekable files. Previously it - exited with an "Illegal seek" error when such a file was replaced. - [bug introduced in fileutils-4.1.6] + + cp --reflink=auto (the default), mv, and install + will again fall back to a standard copy in more cases. + Previously copies could fail with permission errors on diff --git a/src/pr.c b/src/pr.c index 2c5cdceb1..14a368b6c 100644 --- a/src/pr.c diff --git a/backport-sort-fix-sort-g-infloop-again.patch b/backport-sort-fix-sort-g-infloop-again.patch deleted file mode 100644 index 7ad4f1e372142eb1f72aa7dfaf0a88ea9086dbce..0000000000000000000000000000000000000000 --- a/backport-sort-fix-sort-g-infloop-again.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 2f56f5a42033dc6db15d8963e54566f01fa0d61d Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Sun, 1 May 2022 22:46:21 -0700 -Subject: [PATCH] sort: fix sort -g infloop again - -Problem reported by Giulio Genovese (Bug#55212). -* src/sort.c (nan_compare): To compare NaNs, simply printf+strcmp. -This avoids the problem of padding bits and unspecified behavior. -Args are now long double instead of char *; caller changed. ---- - src/sort.c | 21 ++++++--------------- - 1 files changed, 6 insertions(+), 15 deletions(-) - -diff --git a/src/sort.c b/src/sort.c -index 3b775d6bb..b2a465cf5 100644 ---- a/src/sort.c -+++ b/src/sort.c -@@ -2359,22 +2359,13 @@ numcompare (char const *a, char const *b) - } - #endif /* HAV_EMBRTOWC */ - --/* Work around a problem whereby the long double value returned by glibc's -- strtold ("NaN", ...) contains uninitialized bits: clear all bytes of -- A and B before calling strtold. FIXME: remove this function if -- gnulib guarantees that strtold's result is always well defined. */ - static int --nan_compare (char const *sa, char const *sb) -+nan_compare (long double a, long double b) - { -- long double a; -- memset (&a, 0, sizeof a); -- a = strtold (sa, NULL); -- -- long double b; -- memset (&b, 0, sizeof b); -- b = strtold (sb, NULL); -- -- return memcmp (&a, &b, sizeof a); -+ char buf[2][sizeof "-nan()" + CHAR_BIT * sizeof a]; -+ snprintf (buf[0], sizeof buf[0], "%Lf", a); -+ snprintf (buf[1], sizeof buf[1], "%Lf", b); -+ return strcmp (buf[0], buf[1]); - } - - static int -@@ -2402,7 +2393,7 @@ general_numcompare (char const *sa, char const *sb) - : a == b ? 0 - : b == b ? -1 - : a == a ? 1 -- : nan_compare (sa, sb)); -+ : nan_compare (a, b)); - } - - /* Return an integer in 1..12 of the month name MONTH. --- -2.27.0 - diff --git a/backport-stat-only-automount-with-cached-never.patch b/backport-stat-only-automount-with-cached-never.patch deleted file mode 100644 index 0c7df8bd355168397094d851242115da8c9e57dd..0000000000000000000000000000000000000000 --- a/backport-stat-only-automount-with-cached-never.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 92cb8427c537f37edd43c5cef1909585201372ab Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?P=C3=A1draig=20Brady?= -Date: Mon, 7 Mar 2022 23:29:20 +0000 -Subject: [PATCH] stat: only automount with --cached=never - -Revert to the default behavior before the introduction of statx(). - -* src/stat.c (do_stat): Set AT_NO_AUTOMOUNT without --cached=never. -* doc/coreutils.texi (stat invocation): Mention the automount -behavior with --cached=never. -* NEWS: Mention the change in behavior. - -Fixes https://bugs.gnu.org/54287 ---- - doc/coreutils.texi | 1 + - src/stat.c | 3 +++ - 2 files changed, 4 insertions(+) - -diff --git a/doc/coreutils.texi b/doc/coreutils.texi -index e9be0993ac..05dc5ee21f 100644 ---- a/doc/coreutils.texi -+++ b/doc/coreutils.texi -@@ -12608,6 +12608,7 @@ Always read the already cached attributes if available. - - @item never - Always sychronize with the latest file system attributes. -+This also mounts automounted files. - - @item default - Leave the caching behavior to the underlying file system. -diff --git a/src/stat.c b/src/stat.c -index edafd02854..3765a8f65a 100644 ---- a/src/stat.c -+++ b/src/stat.c -@@ -1394,6 +1394,9 @@ do_stat (char const *filename, char const *format, char const *format2) - else if (force_sync) - flags |= AT_STATX_FORCE_SYNC; - -+ if (! force_sync) -+ flags |= AT_NO_AUTOMOUNT; -+ - fd = statx (fd, pathname, flags, format_to_mask (format), &stx); - if (fd < 0) - { diff --git a/backport-stty-fix-off-by-one-column-wrapping-on-output.patch b/backport-stty-fix-off-by-one-column-wrapping-on-output.patch deleted file mode 100644 index c7b9c257eac9c818a2b5e5cb5e658a6b0ec98b19..0000000000000000000000000000000000000000 --- a/backport-stty-fix-off-by-one-column-wrapping-on-output.patch +++ /dev/null @@ -1,66 +0,0 @@ -From c9a21ec3173b93de4839e5ff9eddadb020431656 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?P=C3=A1draig=20Brady?= -Date: Sat, 31 Dec 2022 17:03:39 +0000 -Subject: [PATCH] stty: fix off by one column wrapping on output - -* src/stty.c (wrapf): Adjust the comparison by 1, -to account for the space we're adding. -* tests/misc/stty.sh: Add a test case. -* NEWS: Mention the fix. -Reported in https://bugs.debian.org/1027442 - -Refernece:https://github.com/coreutils/coreutils/commit/c9a21ec3173b93de4839e5ff9eddadb020431656 -Conflict:NEWS Context adapation - ---- - NEWS | 4 ++++ - src/stty.c | 2 +- - tests/misc/stty.sh | 6 ++++++ - 3 files changed, 11 insertions(+), 1 deletion(-) - -diff --git a/NEWS b/NEWS -index 805f012..9d3f253 100644 ---- a/NEWS -+++ b/NEWS -@@ -3,6 +3,10 @@ GNU coreutils NEWS - * Noteworthy changes in release 9.0 (2021-09-24) [stable] - - ** Bug fixes -+ stty now wraps output appropriately for the terminal width. -+ Previously it may have output 1 character too wide for certain widths. -+ [bug introduced in coreutils-5.3] -+ - stty ispeed and ospeed options no longer accept and silently ignore - invalid speed arguments. Now they're validated against both the - general accepted set, and the system supported set of valid speeds. -diff --git a/src/stty.c b/src/stty.c -index b4c2cbecd..f3c7915e1 100644 ---- a/src/stty.c -+++ b/src/stty.c -@@ -519,7 +519,7 @@ wrapf (char const *message,...) - - if (0 < current_col) - { -- if (max_col - current_col < buflen) -+ if (max_col - current_col <= buflen) - { - putchar ('\n'); - current_col = 0; -diff --git a/tests/misc/stty.sh b/tests/misc/stty.sh -index bcdc80e87..7abcec5af 100755 ---- a/tests/misc/stty.sh -+++ b/tests/misc/stty.sh -@@ -89,4 +89,10 @@ returns_ 1 strace -o log2 -e ioctl stty -blahblah || fail=1 - n_ioctl2=$(wc -l < log2) || framework_failure_ - test "$n_ioctl1" = "$n_ioctl2" || fail=1 - -+# Ensure we wrap output appropriately -+for W in $(seq 80 90); do -+ output_width=$(COLUMNS="$W" stty -a | wc -L) -+ test "$output_width" -le "$W" || fail=1 -+done -+ - Exit $fail --- -2.27.0 - diff --git a/backport-stty-validate-ispeed-and-ospeed-arguments.patch b/backport-stty-validate-ispeed-and-ospeed-arguments.patch deleted file mode 100644 index ed9f6691b999e72972e8d6cb1d23dc78ddfd6cad..0000000000000000000000000000000000000000 --- a/backport-stty-validate-ispeed-and-ospeed-arguments.patch +++ /dev/null @@ -1,110 +0,0 @@ -From f87a78f334f25cbaac89507c8fda24d4f780b908 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?P=C3=A1draig=20Brady?= -Date: Wed, 31 Aug 2022 00:17:21 +0100 -Subject: [PATCH] stty: validate ispeed and ospeed arguments - -* src/stty.c (apply_settings): Validate [io]speed arguments -against the internal accepted set. -(set_speed): Check the cfset[io]speed() return value so -that we validate against the system supported set. -* tests/misc/stty-invalid.sh: Add a test case. -* NEWS: Mention the bug fix. -Reported in https://bugs.debian.org/1018790 - -Reference:https://github.com/coreutils/coreutils/commit/f87a78f334f25cbaac89507c8fda24d4f780b908 -Conflict:Context adapation - ---- - NEWS | 5 +++++ - src/stty.c | 29 +++++++++++++++++++++++++---- - tests/misc/stty-invalid.sh | 3 +++ - 3 files changed, 33 insertions(+), 4 deletions(-) - -diff --git a/NEWS b/NEWS -index f2fbcbb..805f012 100644 ---- a/NEWS -+++ b/NEWS -@@ -3,6 +3,10 @@ GNU coreutils NEWS - * Noteworthy changes in release 9.0 (2021-09-24) [stable] - - ** Bug fixes -+ stty ispeed and ospeed options no longer accept and silently ignore -+ invalid speed arguments. Now they're validated against both the -+ general accepted set, and the system supported set of valid speeds. -+ [This bug was present in "the beginning".] - - chmod -v no longer misreports modes of dangling symlinks. - [bug introduced in coreutils-5.3.0] -diff --git a/src/stty.c b/src/stty.c -index 3b6a592a9..3d515223e 100644 ---- a/src/stty.c -+++ b/src/stty.c -@@ -1159,6 +1159,11 @@ apply_settings (bool checking, char const *device_name, - { - check_argument (arg); - ++k; -+ if (string_to_baud (settings[k]) == (speed_t) -1) -+ { -+ error (0, 0, _("invalid ispeed %s"), quote (settings[k])); -+ usage (EXIT_FAILURE); -+ } - if (checking) - continue; - set_speed (input_speed, settings[k], mode); -@@ -1169,6 +1174,11 @@ apply_settings (bool checking, char const *device_name, - { - check_argument (arg); - ++k; -+ if (string_to_baud (settings[k]) == (speed_t) -1) -+ { -+ error (0, 0, _("invalid ospeed %s"), quote (settings[k])); -+ usage (EXIT_FAILURE); -+ } - if (checking) - continue; - set_speed (output_speed, settings[k], mode); -@@ -1696,13 +1706,24 @@ set_control_char (struct control_info const *info, char const *arg, - static void - set_speed (enum speed_setting type, char const *arg, struct termios *mode) - { -- speed_t baud; -+ /* Note cfset[io]speed(), do not check with the device, -+ and only check whether the system logic supports the specified speed. -+ Therefore we don't report the device name in any errors. */ -+ -+ speed_t baud = string_to_baud (arg); -+ -+ assert (baud != (speed_t) -1); - -- baud = string_to_baud (arg); - if (type == input_speed || type == both_speeds) -- cfsetispeed (mode, baud); -+ { -+ if (cfsetispeed (mode, baud)) -+ die (EXIT_FAILURE, 0, "unsupported ispeed %s", quotef (arg)); -+ } - if (type == output_speed || type == both_speeds) -- cfsetospeed (mode, baud); -+ { -+ if (cfsetospeed (mode, baud)) -+ die (EXIT_FAILURE, 0, "unsupported ospeed %s", quotef (arg)); -+ } - } - - #ifdef TIOCGWINSZ -diff --git a/tests/misc/stty-invalid.sh b/tests/misc/stty-invalid.sh -index 58e51311d..af49b8d89 100755 ---- a/tests/misc/stty-invalid.sh -+++ b/tests/misc/stty-invalid.sh -@@ -50,6 +50,9 @@ if tty -s -Date: Mon, 30 Jan 2023 21:44:10 +0000 -Subject: [PATCH] tail: fix support for -F with non seekable files - -This was seen to be an issue when following a -symlink that was being updated to point to -different underlying devices. - -* src/tail.c (recheck): Guard the lseek() call to only -be performed for regular files. -* NEWS: Mention the bug fix. - -Reference:https://github.com/coreutils/coreutils/commit/c0c63e9735908a9579f8735001957db6bd81afc3 -Conflict:NEWS Context adapation - ---- - NEWS | 4 ++++ - src/tail.c | 3 ++- - 2 files changed, 6 insertions(+), 1 deletion(-) - -diff --git a/NEWS b/NEWS -index b65bc85..f65eb95 100644 ---- a/NEWS -+++ b/NEWS -@@ -3,6 +3,10 @@ GNU coreutils NEWS -*- outline -*- - * Noteworthy changes in release 9.0 (2021-09-24) [stable] - - ** Bug fixes -+ tail --follow=name works again with non seekable files. Previously it -+ exited with an "Illegal seek" error when such a file was replaced. -+ [bug introduced in fileutils-4.1.6] -+ - cp, mv, and install now handle ENOENT failures across CIFS file systems, - falling back from copy_file_range to a better supported standard copy. - [issue introduced in coreutils-9.0] -diff --git a/src/tail.c b/src/tail.c -index 2244509dd..03061e8bf 100644 ---- a/src/tail.c -+++ b/src/tail.c -@@ -1122,7 +1122,8 @@ recheck (struct File_spec *f, bool blocking) - { - /* Start at the beginning of the file. */ - record_open_fd (f, fd, 0, &new_stats, (is_stdin ? -1 : blocking)); -- xlseek (fd, 0, SEEK_SET, pretty_name (f)); -+ if (S_ISREG (new_stats.st_mode)) -+ xlseek (fd, 0, SEEK_SET, pretty_name (f)); - } - } - --- -2.27.0 - diff --git a/backport-tests-sort-NaN-infloop-augment-testing-for-recent-fi.patch b/backport-tests-sort-NaN-infloop-augment-testing-for-recent-fi.patch deleted file mode 100644 index b02ae610dfecccf34cc7963e653afb44c44a04fe..0000000000000000000000000000000000000000 --- a/backport-tests-sort-NaN-infloop-augment-testing-for-recent-fi.patch +++ /dev/null @@ -1,43 +0,0 @@ -From ddafdae21c574b1dcd5c56e403c82010e7ed3565 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?P=C3=A1draig=20Brady?= -Date: Mon, 2 May 2022 14:27:34 +0100 -Subject: [PATCH] tests: sort-NaN-infloop: augment testing for recent fix - -* tests/misc/sort-NaN-infloop.sh: Add test case from -https://unix.stackexchange.com/a/700967/37127 -* src/sort.c: Avoid syntax-check failure. ---- - src/sort.c | 2 +- - tests/misc/sort-NaN-infloop.sh | 3 +++ - 2 files changed, 4 insertions(+), 1 deletion(-) - -diff --git a/src/sort.c b/src/sort.c -index b2a465cf5..8af356c66 100644 ---- a/src/sort.c -+++ b/src/sort.c -@@ -2006,7 +2006,7 @@ numcompare (char const *a, char const *b) - static int - nan_compare (long double a, long double b) - { -- char buf[2][sizeof "-nan()" + CHAR_BIT * sizeof a]; -+ char buf[2][sizeof "-nan""()" + CHAR_BIT * sizeof a]; - snprintf (buf[0], sizeof buf[0], "%Lf", a); - snprintf (buf[1], sizeof buf[1], "%Lf", b); - return strcmp (buf[0], buf[1]); -diff --git a/tests/misc/sort-NaN-infloop.sh b/tests/misc/sort-NaN-infloop.sh -index 93cf9bd77..cc1c583cd 100755 ---- a/tests/misc/sort-NaN-infloop.sh -+++ b/tests/misc/sort-NaN-infloop.sh -@@ -23,6 +23,9 @@ echo nan > F || framework_failure_ - printf 'nan\nnan\n' > exp || framework_failure_ - timeout 10 sort -g -m F F > out || fail=1 - -+# This was seen to infloop on some systems until coreutils v9.2 (bug 55212) -+yes nan | head -n128095 | timeout 60 sort -g > /dev/null || fail=1 -+ - compare exp out || fail=1 - - Exit $fail --- -2.27.0 - diff --git a/backport-timeout-ensure-foreground-k-exits-with-status-137.patch b/backport-timeout-ensure-foreground-k-exits-with-status-137.patch deleted file mode 100644 index 8e453587eab2ab0e5fa241394e2b004522517ef8..0000000000000000000000000000000000000000 --- a/backport-timeout-ensure-foreground-k-exits-with-status-137.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0750fcdf3447366b074cb47dd8cbe88c83ed984d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?P=C3=A1draig=20Brady?= -Date: Tue, 12 Oct 2021 14:32:57 +0100 -Subject: [PATCH] timeout: ensure --foreground -k exits with status 137 - -* src/timeout.c (main): Propagate the killed status from the child. -* doc/coreutils.texi (timeout invocation): Remove the -description of the --foreground specific handling of SIGKILL, -now that it's consistent with the default mode of operation. -* tests/misc/timeout.sh: Add a test case. -* NEWS: Mention the change in behavior. -Fixes https://bugs.gnu.org/51135 ---- - src/timeout.c | 5 +++++ - tests/misc/timeout.sh | 3 +++ - 2 files changed, 15 insertions(+), 3 deletions(-) - -diff --git a/src/timeout.c b/src/timeout.c -index 34d7926408..6505634617 100644 ---- a/src/timeout.c -+++ b/src/timeout.c -@@ -593,6 +593,11 @@ main (int argc, char **argv) - unblock_signal (sig); - raise (sig); - } -+ /* Allow users to distinguish if command was forcably killed. -+ Needed with --foreground where we don't send SIGKILL to -+ the timeout process itself. */ -+ if (timed_out && sig == SIGKILL) -+ preserve_status = true; - status = sig + 128; /* what sh returns for signaled processes. */ - } - else -diff --git a/tests/misc/timeout.sh b/tests/misc/timeout.sh -index 44ca450d81..295a95773b 100755 ---- a/tests/misc/timeout.sh -+++ b/tests/misc/timeout.sh -@@ -42,7 +42,10 @@ returns_ 124 timeout --preserve-status .1 sleep 10 && fail=1 - # kill delay. Note once the initial timeout triggers, - # the exit status will be 124 even if the command - # exits on its own accord. -+# exit status should be 128+KILL - returns_ 124 timeout -s0 -k1 .1 sleep 10 && fail=1 -+# Ensure a consistent exit status with --foreground -+returns_ 124 timeout --foreground -s0 -k1 .1 sleep 10 && fail=1 - - # Ensure 'timeout' is immune to parent's SIGCHLD handler - # Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh. diff --git a/backport-wc-ensure-we-update-file-offset.patch b/backport-wc-ensure-we-update-file-offset.patch deleted file mode 100644 index 723fdef6ba3fb968daeed59eba3fcdc8a82eea3a..0000000000000000000000000000000000000000 --- a/backport-wc-ensure-we-update-file-offset.patch +++ /dev/null @@ -1,75 +0,0 @@ -From ce630dfc7ef32ff7e35c627bd061a45ce9053d9d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?P=C3=A1draig=20Brady?= -Date: Sun, 5 Feb 2023 19:52:31 +0000 -Subject: [PATCH] wc: ensure we update file offset - -* src/wc.c (wc): Update the offset when not reading, -and do read if we can't update the offset. -* tests/misc/wc-proc.sh: Add a test case. -* NEWS: Mention the bug fix. -Fixes https://bugs.gnu.org/61300 - -Conflict:NEWS and tests/misc/wc-proc.sh context adaption -Reference:https://github.com/coreutils/coreutils/commit/ce630dfc7ef32ff7e35c627bd061a45ce9053d9d - ---- - NEWS | 4 ++++ - src/wc.c | 5 ++++- - tests/misc/wc-proc.sh | 12 ++++++++++++ - 3 files changed, 20 insertions(+), 1 deletion(-) - -diff --git a/NEWS b/NEWS -index 5320b9c..ce6e2b7 100644 ---- a/NEWS -+++ b/NEWS -@@ -3,6 +3,10 @@ GNU coreutils NEWS -*- outline -*- - * Noteworthy changes in release 9.0 (2021-09-24) [stable] - - ** Bug fixes -+ `wc -c` will again correctly update the read offset of inputs. -+ Previously it deduced the size of inputs while leaving the offset unchanged. -+ [bug introduced in coreutils-8.27] -+ - 'pr --length=1 --double-space' no longer enters an infinite loop. - [This bug was present in "the beginning".] - -diff --git a/src/wc.c b/src/wc.c -index 801396a15..becceda98 100644 ---- a/src/wc.c -+++ b/src/wc.c -@@ -450,7 +450,10 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos) - beyond the end of the file. As in the example above. */ - - bytes = end_pos < current_pos ? 0 : end_pos - current_pos; -- skip_read = true; -+ if (bytes && 0 <= lseek (fd, bytes, SEEK_CUR)) -+ skip_read = true; -+ else -+ bytes = 0; - } - else - { -diff --git a/tests/misc/wc-proc.sh b/tests/misc/wc-proc.sh -index 5eb43b982..2307f2c38 100755 ---- a/tests/misc/wc-proc.sh -+++ b/tests/misc/wc-proc.sh -@@ -42,4 +42,16 @@ cat <<\EOF > exp - EOF - compare exp out || fail=1 - -+# Ensure we update the offset even when not reading, -+# which wasn't the case from coreutils-8.27 to coreutils-9.2 -+{ wc -c; wc -c; } < no_read > out || fail=1 -+{ wc -c; wc -c; } < do_read >> out || fail=1 -+cat <<\EOF > exp -+2 -+0 -+1048576 -+0 -+EOF -+compare exp out || fail=1 -+ - Exit $fail --- -2.36.1 - diff --git a/bugfix-dummy_help2man.patch b/bugfix-dummy_help2man.patch index c4fc4f0fe4872c085c47eb1566aed6fe70768c92..936162e42ad3ff3c113ab804b74ca8236298388b 100644 --- a/bugfix-dummy_help2man.patch +++ b/bugfix-dummy_help2man.patch @@ -2,15 +2,21 @@ diff --git a/man/local.mk b/man/local.mk index 05d4401..601f459 100644 --- a/man/local.mk +++ b/man/local.mk -@@ -23,11 +23,11 @@ if CROSS_COMPILING +@@ -23,14 +23,14 @@ if CROSS_COMPILING run_help2man = $(SHELL) $(srcdir)/man/dummy-man else ## Graceful degradation for systems lacking perl. -if HAVE_PERL --run_help2man = $(PERL) -- $(srcdir)/man/help2man +-if BOLD_MAN_REFS +-help2man_OPTS=--bold-refs +-endif +-run_help2man = $(PERL) -- $(srcdir)/man/help2man $(help2man_OPTS) -else +#if HAVE_PERL -+#run_help2man = $(PERL) -- $(srcdir)/man/help2man ++#if BOLD_MAN_REFS ++#help2man_OPTS=--bold-refs ++#endif ++#run_help2man = $(PERL) -- $(srcdir)/man/help2man $(help2man_OPTS) +#else run_help2man = $(SHELL) $(srcdir)/man/dummy-man -endif diff --git a/bugfix-selinux-flask.patch b/bugfix-selinux-flask.patch deleted file mode 100644 index 83839fa7bc79a53303b174c38b703c6f09cc3f9b..0000000000000000000000000000000000000000 --- a/bugfix-selinux-flask.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 1e764c5b9a3eb9a73370dbcbc04c2462c31aaf45 Mon Sep 17 00:00:00 2001 -From: openEuler Buildteam -Date: Wed, 29 Jul 2020 11:55:45 +0800 -Subject: [PATCH] bugfix selinux flask - ---- - m4/gnulib-comp.m4 | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 -index dead90e..0abf0bd 100644 ---- a/m4/gnulib-comp.m4 -+++ b/m4/gnulib-comp.m4 -@@ -1860,11 +1860,11 @@ AC_DEFUN([gl_INIT], - AC_LIBOBJ([select]) - fi - gl_SYS_SELECT_MODULE_INDICATOR([select]) -- AC_CHECK_HEADERS([selinux/flask.h]) - gl_HEADERS_SELINUX_SELINUX_H - gl_HEADERS_SELINUX_CONTEXT_H - gl_HEADERS_SELINUX_LABEL_H - if test "$with_selinux" != no && test "$ac_cv_header_selinux_selinux_h" = yes; then -+ AC_CHECK_HEADERS([selinux/flask.h]) - AC_LIBOBJ([getfilecon]) - fi - gl_SERVENT --- -2.23.0 - diff --git a/coreutils-8.2-uname-processortype.patch b/coreutils-8.2-uname-processortype.patch index ed01ab80d03c9f619f49bb05051702f5876a800e..6996d169708aba650ff95d1c46ceefd7ea96ebd3 100644 --- a/coreutils-8.2-uname-processortype.patch +++ b/coreutils-8.2-uname-processortype.patch @@ -1,29 +1,30 @@ diff --git a/src/uname.c b/src/uname.c -index 6371ca2..1ad8fd7 100644 +index 921a881..512655d 100644 --- a/src/uname.c +++ b/src/uname.c -@@ -300,13 +300,19 @@ main (int argc, char **argv) +@@ -313,7 +313,7 @@ main (int argc, char **argv) if (toprint & PRINT_PROCESSOR) { - char const *element = unknown; + char *element = unknown; - #if HAVE_SYSINFO && defined SI_ARCHITECTURE - { - static char processor[257]; - if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor)) - element = processor; - } + #ifdef __APPLE__ + # if defined __arm__ || defined __arm64__ + element = "arm"; +@@ -330,6 +330,12 @@ main (int argc, char **argv) + if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor)) + element = processor; + } +#else + { -+ static struct utsname u; -+ uname(&u); -+ element = u.machine; ++ static struct utsname u; ++ uname(&u); ++ element = u.machine; + } #endif #ifdef UNAME_PROCESSOR if (element == unknown) -@@ -344,7 +350,7 @@ main (int argc, char **argv) +@@ -347,7 +353,7 @@ main (int argc, char **argv) if (toprint & PRINT_HARDWARE_PLATFORM) { @@ -32,17 +33,17 @@ index 6371ca2..1ad8fd7 100644 #if HAVE_SYSINFO && defined SI_PLATFORM { static char hardware_platform[257]; -@@ -352,6 +358,14 @@ main (int argc, char **argv) +@@ -355,6 +361,14 @@ main (int argc, char **argv) hardware_platform, sizeof hardware_platform)) element = hardware_platform; } +#else + { -+ static struct utsname u; -+ uname(&u); -+ element = u.machine; -+ if(strlen(element)==4 && element[0]=='i' && element[2]=='8' && element[3]=='6') -+ element[1]='3'; ++ static struct utsname u; ++ uname(&u); ++ element = u.machine; ++ if(strlen(element)==4 && element[0]=='i' && element[2]=='8' && element[3]=='6') ++ element[1]='3'; + } #endif #ifdef UNAME_HARDWARE_PLATFORM diff --git a/coreutils-9.0.tar.xz b/coreutils-9.3.tar.xz similarity index 43% rename from coreutils-9.0.tar.xz rename to coreutils-9.3.tar.xz index 782c214d2ab0445bf7b16c933838b5f88c16d198..25944bb718e53b58bd361fc50e2142fa837ee1b1 100644 Binary files a/coreutils-9.0.tar.xz and b/coreutils-9.3.tar.xz differ diff --git a/coreutils.spec b/coreutils.spec index a966b8af857f662372d226bbbd3cc487ab5cdcf8..1a80becefd5b78a9297ae4549e58a959569ab28c 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,6 +1,6 @@ Name: coreutils -Version: 9.0 -Release: 10 +Version: 9.3 +Release: 1 License: GPLv3+ Summary: A set of basic GNU tools commonly used in shell scripts Url: https://www.gnu.org/software/coreutils/ @@ -17,28 +17,10 @@ Patch1: coreutils-8.2-uname-processortype.patch Patch2: coreutils-getgrouplist.patch Patch3: bugfix-remove-usr-local-lib-from-m4.patch Patch4: bugfix-dummy_help2man.patch -Patch5: bugfix-selinux-flask.patch Patch6: skip-the-tests-that-require-selinux-if-selinux-is-di.patch -Patch7: backport-chmod-fix-exit-status-when-ignoring-symlinks.patch -Patch8: backport-timeout-ensure-foreground-k-exits-with-status-137.patch -Patch9: backport-dd-improve-integer-overflow-checking.patch -Patch10: backport-dd-do-not-access-uninitialized.patch -Patch11: backport-df-fix-memory-leak.patch -Patch12: backport-ls-avoid-triggering-automounts.patch -Patch13: backport-stat-only-automount-with-cached-never.patch -Patch14: backport-config-color-alias-for-ls.patch -Patch15: backport-coreutils-i18n.patch -Patch16: backport-sort-fix-sort-g-infloop-again.patch -Patch17: backport-tests-sort-NaN-infloop-augment-testing-for-recent-fi.patch -Patch18: backport-comm-fix-NUL-output-delimiter-with-total.patch -Patch19: backport-stty-validate-ispeed-and-ospeed-arguments.patch -Patch20: backport-fts-fix-race-mishandling-of-fstatat-failure.patch -Patch21: backport-stty-fix-off-by-one-column-wrapping-on-output.patch -Patch22: backport-copy-copy_file_range-handle-ENOENT-for-CIFS.patch -Patch23: backport-tail-fix-support-for-F-with-non-seekable-files.patch -Patch24: backport-fts-fail-gracefully-when-out-of-memory.patch -Patch25: backport-pr-fix-infinite-loop-when-double-spacing.patch -Patch26: backport-wc-ensure-we-update-file-offset.patch +Patch7: backport-config-color-alias-for-ls.patch +Patch8: backport-coreutils-i18n.patch +Patch9: backport-pr-fix-infinite-loop-when-double-spacing.patch Patch9000: openEuler-coreutils-df-direct.patch %ifarch sw_64 @@ -166,6 +148,9 @@ fi %{_mandir}/man*/* %changelog +* Wed Jul 12 2023 jiangchuangang - 9.3-1 +- update to 9.3 + * Thu Jun 15 2023 jiangchuangang - 9.0-10 - sync patches from community - add backport-pr-fix-infinite-loop-when-double-spacing.patch