new upstream release 8.28

This commit is contained in:
Kamil Dudka 2017-08-29 14:21:49 +02:00
parent 3490621545
commit 2d00e2bb9a
12 changed files with 94 additions and 1093 deletions

View File

@ -1,189 +0,0 @@
From fc286e2b3af5b2ed9aec44b520265bb0968f1660 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Mon, 24 Apr 2017 01:43:36 -0700
Subject: [PATCH 1/2] time_rz: fix heap buffer overflow vulnerability
This issue has been assigned CVE-2017-7476 and was
detected with American Fuzzy Lop 2.41b run on the
coreutils date(1) program with ASAN enabled.
ERROR: AddressSanitizer: heap-buffer-overflow on address 0x...
WRITE of size 8 at 0x60d00000cff8 thread T0
#1 0x443020 in extend_abbrs lib/time_rz.c:88
#2 0x443356 in save_abbr lib/time_rz.c:155
#3 0x44393f in localtime_rz lib/time_rz.c:290
#4 0x41e4fe in parse_datetime2 lib/parse-datetime.y:1798
A minimized reproducer is the following 120 byte TZ value,
which goes beyond the value of ABBR_SIZE_MIN (119) on x86_64.
Extend the aa...b portion to overwrite more of the heap.
date -d $(printf 'TZ="aaa%020daaaaaab%089d"')
localtime_rz and mktime_z were affected since commit 4bc76593.
parse_datetime was affected since commit 4e6e16b3f.
* lib/time_rz.c (save_abbr): Rearrange the calculation determining
whether there is enough buffer space available. The rearrangement
ensures we're only dealing with positive numbers, thus avoiding
the problematic promotion of signed to unsigned causing an invalid
comparison when zone_copy is more than ABBR_SIZE_MIN bytes beyond
the start of the buffer.
* tests/test-parse-datetime.c (main): Add a test case written by
Paul Eggert, which overwrites enough of the heap so that
standard glibc will fail with "free(): invalid pointer"
without the patch applied.
Reported and analyzed at https://bugzilla.redhat.com/1444774
Upstream-commit: 94e01571507835ff59dd8ce2a0b56a4b566965a4
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
gnulib-tests/test-parse-datetime.c | 16 ++++++++++++++++
lib/time_rz.c | 15 +++++++++++++--
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/gnulib-tests/test-parse-datetime.c b/gnulib-tests/test-parse-datetime.c
index b42a51c..b6fe457 100644
--- a/gnulib-tests/test-parse-datetime.c
+++ b/gnulib-tests/test-parse-datetime.c
@@ -432,5 +432,21 @@ main (int argc _GL_UNUSED, char **argv)
ASSERT ( parse_datetime (&result, "TZ=\"\\\\\"", &now));
ASSERT ( parse_datetime (&result, "TZ=\"\\\"\"", &now));
+ /* Outlandishly-long time zone abbreviations should not cause problems. */
+ {
+ static char const bufprefix[] = "TZ=\"";
+ enum { tzname_len = 2000 };
+ static char const bufsuffix[] = "0\" 1970-01-01 01:02:03.123456789";
+ enum { bufsize = sizeof bufprefix - 1 + tzname_len + sizeof bufsuffix };
+ char buf[bufsize];
+ memcpy (buf, bufprefix, sizeof bufprefix - 1);
+ memset (buf + sizeof bufprefix - 1, 'X', tzname_len);
+ strcpy (buf + bufsize - sizeof bufsuffix, bufsuffix);
+ ASSERT (parse_datetime (&result, buf, &now));
+ LOG (buf, now, result);
+ ASSERT (result.tv_sec == 1 * 60 * 60 + 2 * 60 + 3
+ && result.tv_nsec == 123456789);
+ }
+
return 0;
}
diff --git a/lib/time_rz.c b/lib/time_rz.c
index adb9c1c..c41a8ef 100644
--- a/lib/time_rz.c
+++ b/lib/time_rz.c
@@ -27,6 +27,7 @@
#include <time.h>
#include <errno.h>
+#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
@@ -35,6 +36,10 @@
#include "flexmember.h"
#include "time-internal.h"
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
#if !HAVE_TZSET
static void tzset (void) { }
#endif
@@ -43,7 +48,7 @@ static void tzset (void) { }
the largest "small" request for the GNU C library malloc. */
enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
-/* Minimum size of the ABBRS member of struct abbr. ABBRS is larger
+/* Minimum size of the ABBRS member of struct tm_zone. ABBRS is larger
only in the unlikely case where an abbreviation longer than this is
used. */
enum { ABBR_SIZE_MIN = DEFAULT_MXFAST - offsetof (struct tm_zone, abbrs) };
@@ -150,7 +155,13 @@ save_abbr (timezone_t tz, struct tm *tm)
if (! (*zone_copy || (zone_copy == tz->abbrs && tz->tz_is_set)))
{
size_t zone_size = strlen (zone) + 1;
- if (zone_size < tz->abbrs + ABBR_SIZE_MIN - zone_copy)
+ size_t zone_used = zone_copy - tz->abbrs;
+ if (SIZE_MAX - zone_used < zone_size)
+ {
+ errno = ENOMEM;
+ return false;
+ }
+ if (zone_used + zone_size < ABBR_SIZE_MIN)
extend_abbrs (zone_copy, zone, zone_size);
else
{
--
2.9.3
From 9579f90484c71e5a22f32f35189192a82e47550e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Wed, 26 Apr 2017 20:51:39 -0700
Subject: [PATCH 2/2] date,touch: test and document large TZ security issue
Add a test for CVE-2017-7476 which was fixed in gnulib at:
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=94e01571
* tests/misc/date-tz.sh: Add a new test which overwrites enough
of the heap to trigger a segfault, even without ASAN enabled.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Upstream-commit: 9287ef2b1707e2a222f8ae776ce3785abcb16fba
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
tests/local.mk | 1 +
tests/misc/date-tz.sh | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+)
create mode 100755 tests/misc/date-tz.sh
diff --git a/tests/local.mk b/tests/local.mk
index 9f1a853..ec0b414 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -282,6 +282,7 @@ all_tests = \
tests/misc/csplit-suppress-matched.pl \
tests/misc/date-debug.sh \
tests/misc/date-sec.sh \
+ tests/misc/date-tz.sh \
tests/misc/dircolors.pl \
tests/misc/dirname.pl \
tests/misc/env-null.sh \
diff --git a/tests/misc/date-tz.sh b/tests/misc/date-tz.sh
new file mode 100755
index 0000000..3fe1579
--- /dev/null
+++ b/tests/misc/date-tz.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Verify TZ processing.
+
+# Copyright (C) 2017 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ date
+
+# coreutils-8.27 would overwrite the heap with large TZ values
+tz_long=$(printf '%2000s' | tr ' ' a)
+date -d "TZ=\"${tz_long}0\" 2017" || fail=1
+
+Exit $fail
--
2.9.3

View File

@ -1,50 +0,0 @@
From ee2017f191f1ad177405fbd8816df0a55127804a Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 9 Mar 2017 23:59:05 -0800
Subject: [PATCH] tests: port to tzdb-2017a
Problem reported by Bernhard Voelker in:
http://lists.gnu.org/archive/html/coreutils/2017-03/msg00026.html
* tests/misc/date-debug.sh: Port test to tzdb 2017a,
and future-proof the America/Belize test.
Upstream-commit: 612086660bab9bf981894da146550e9101224b17
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
tests/misc/date-debug.sh | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/tests/misc/date-debug.sh b/tests/misc/date-debug.sh
index 48f4605..8e0b2af 100755
--- a/tests/misc/date-debug.sh
+++ b/tests/misc/date-debug.sh
@@ -52,10 +52,11 @@ date: output timezone: +09:00 (set from TZ="Asia/Tokyo" environment value)
date: final: 661095000.000000000 (epoch-seconds)
date: final: (Y-M-D) 1990-12-13 13:30:00 (UTC0)
date: final: (Y-M-D) 1990-12-13 22:30:00 (output timezone TZ=+09:00)
-Thu Dec 13 07:30:00 CST 1990
+Thu Dec 13 07:30:00 -0600 1990
EOF
-TZ=America/Belize date --debug -d "$in1" >out1 2>&1 || fail=1
+TZ=America/Belize date --debug -d "$in1" +'%a %b %e %T %z %Y' >out1 2>&1 ||
+ fail=1
compare exp1 out1 || fail=1
@@ -94,10 +95,10 @@ date: output timezone: -05:00 (set from TZ="America/Lima" environment value)
date: final: 1.000000000 (epoch-seconds)
date: final: (Y-M-D) 1970-01-01 00:00:01 (UTC0)
date: final: (Y-M-D) 1969-12-31 19:00:01 (output timezone TZ=-05:00)
-Wed Dec 31 19:00:01 PET 1969
+Wed Dec 31 19:00:01 -0500 1969
EOF
-TZ=America/Lima date --debug -d "$in3" >out3 2>&1 || fail=1
+TZ=America/Lima date --debug -d "$in3" +'%a %b %e %T %z %Y' >out3 2>&1 || fail=1
compare exp3 out3 || fail=1
##
--
2.9.3

View File

@ -1,547 +0,0 @@
From 7408a9758924a1ccbabf9fcab401a31ef1b7c755 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 17 Aug 2017 12:02:16 -0700
Subject: [PATCH] ptx: fix some integer overflow bugs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Problem reported by Lukas Zachar at:
http://bugzilla.redhat.com/1482445
* src/ptx.c (line_width, gap_size, maximum_word_length)
(reference_max_width, half_line_width, before_max_width)
(keyafter_max_width, truncation_string_length, compare_words)
(compare_occurs, search_table, find_occurs_in_text, print_spaces)
(fix_output_parameters, define_all_fields):
Use ptrdiff_t, not int, for object offsets and sizes.
(WORD, OCCURS): Use ptrdiff_t, not short int.
(WORD_TABLE, number_of_occurs, generate_all_output):
Prefer ptrdiff_t to size_t where either will do.
(total_line_count, file_line_count, OCCURS, fix_output_parameters)
(define_all_fields):
Use intmax_t, not int, for line counts.
(DELTA): Remove. All uses changed.
(OCCURS, find_occurs_in_text, fix_output_parameters):
Use int, not size_t, for file indexes.
(tail_truncation, before_truncation, keyafter_truncation)
(head_truncation, search_table, define_all_fields)
(generate_all_output):
Use bool for booleans.
(digest_word_file, find_occurs_in_text):
Use x2nrealloc instead of checking for overflow by hand.
(find_occurs_in_text, fix_output_parameters, define_all_fields):
Omit unnecessary cast.
(fix_output_parameters): Dont assume integers fit in 11 digits.
(fix_output_parameters, define_all_fields):
Use sprintf return value rather than calling strlen.
(define_all_fields): Do not rely on sprintf to generate a string
that may contain more than INT_MAX bytes.
(main): Use xstrtoimax, not xstrtoul.
Use xnmalloc to catch integer overflow.
Upstream-commit: 1d9765a764790cc68ec52c16d7ccbf633c404f0e
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/ptx.c | 194 +++++++++++++++++++++++++++++---------------------------------
1 file changed, 91 insertions(+), 103 deletions(-)
diff --git a/src/ptx.c b/src/ptx.c
index c0c9733..2aababf 100644
--- a/src/ptx.c
+++ b/src/ptx.c
@@ -59,9 +59,9 @@
/* Global definitions. */
/* FIXME: There are many unchecked integer overflows in this file,
- that will cause this command to misbehave given large inputs or
- options. Many of the "int" values below should be "size_t" or
- something else like that. */
+ and in theory they could cause this command to have undefined
+ behavior given large inputs or options. This command should
+ diagnose any such overflow and exit. */
/* Program options. */
@@ -77,8 +77,8 @@ static bool gnu_extensions = true; /* trigger all GNU extensions */
static bool auto_reference = false; /* refs are 'file_name:line_number:' */
static bool input_reference = false; /* refs at beginning of input lines */
static bool right_reference = false; /* output refs after right context */
-static int line_width = 72; /* output line width in characters */
-static int gap_size = 3; /* number of spaces between output fields */
+static ptrdiff_t line_width = 72; /* output line width in characters */
+static ptrdiff_t gap_size = 3; /* number of spaces between output fields */
static const char *truncation_string = "/";
/* string used to mark line truncations */
static const char *macro_name = "xx"; /* macro name for roff or TeX output */
@@ -105,8 +105,8 @@ static struct regex_data context_regex; /* end of context */
static struct regex_data word_regex; /* keyword */
/* A BLOCK delimit a region in memory of arbitrary size, like the copy of a
- whole file. A WORD is something smaller, its length should fit in a
- short integer. A WORD_TABLE may contain several WORDs. */
+ whole file. A WORD is similar, except it is intended for smaller regions.
+ A WORD_TABLE may contain several WORDs. */
typedef struct
{
@@ -118,7 +118,7 @@ BLOCK;
typedef struct
{
char *start; /* pointer to beginning of region */
- short int size; /* length of the region */
+ ptrdiff_t size; /* length of the region */
}
WORD;
@@ -126,7 +126,7 @@ typedef struct
{
WORD *start; /* array of WORDs */
size_t alloc; /* allocated length */
- size_t length; /* number of used entries */
+ ptrdiff_t length; /* number of used entries */
}
WORD_TABLE;
@@ -149,10 +149,10 @@ static struct re_registers word_regs;
static char word_fastmap[CHAR_SET_SIZE];
/* Maximum length of any word read. */
-static int maximum_word_length;
+static ptrdiff_t maximum_word_length;
/* Maximum width of any reference used. */
-static int reference_max_width;
+static ptrdiff_t reference_max_width;
/* Ignore and Only word tables. */
@@ -162,9 +162,9 @@ static WORD_TABLE only_table; /* table of words to select */
/* Source text table, and scanning macros. */
static int number_input_files; /* number of text input files */
-static int total_line_count; /* total number of lines seen so far */
+static intmax_t total_line_count; /* total number of lines seen so far */
static const char **input_file_name; /* array of text input file names */
-static int *file_line_count; /* array of 'total_line_count' values at end */
+static intmax_t *file_line_count; /* array of line count values at end */
static BLOCK *text_buffers; /* files to study */
@@ -219,20 +219,18 @@ static BLOCK *text_buffers; /* files to study */
When automatic references are used, the 'reference' value is the
overall line number in all input files read so far, in this case, it
- is of type (int). When input references are used, the 'reference'
+ is of type intmax_t. When input references are used, the 'reference'
value indicates the distance between the keyword beginning and the
- start of the reference field, it is of type (DELTA) and usually
+ start of the reference field, and it fits in ptrdiff_t and is usually
negative. */
-typedef short int DELTA; /* to hold displacement within one context */
-
typedef struct
{
WORD key; /* description of the keyword */
- DELTA left; /* distance to left context start */
- DELTA right; /* distance to right context end */
- int reference; /* reference descriptor */
- size_t file_index; /* corresponding file */
+ ptrdiff_t left; /* distance to left context start */
+ ptrdiff_t right; /* distance to right context end */
+ intmax_t reference; /* reference descriptor */
+ int file_index; /* corresponding file */
}
OCCURS;
@@ -241,7 +239,7 @@ OCCURS;
static OCCURS *occurs_table[1]; /* all words retained from the read text */
static size_t occurs_alloc[1]; /* allocated size of occurs_table */
-static size_t number_of_occurs[1]; /* number of used slots in occurs_table */
+static ptrdiff_t number_of_occurs[1]; /* number of used slots in occurs_table */
/* Communication among output routines. */
@@ -249,10 +247,17 @@ static size_t number_of_occurs[1]; /* number of used slots in occurs_table */
/* Indicate if special output processing is requested for each character. */
static char edited_flag[CHAR_SET_SIZE];
-static int half_line_width; /* half of line width, reference excluded */
-static int before_max_width; /* maximum width of before field */
-static int keyafter_max_width; /* maximum width of keyword-and-after field */
-static int truncation_string_length;/* length of string that flags truncation */
+/* Half of line width, reference excluded. */
+static ptrdiff_t half_line_width;
+
+/* Maximum width of before field. */
+static ptrdiff_t before_max_width;
+
+/* Maximum width of keyword-and-after field. */
+static ptrdiff_t keyafter_max_width;
+
+/* Length of string that flags truncation. */
+static ptrdiff_t truncation_string_length;
/* When context is limited by lines, wraparound may happen on final output:
the 'head' pointer gives access to some supplementary left context which
@@ -261,16 +266,16 @@ static int truncation_string_length;/* length of string that flags truncation */
beginning of the output line. */
static BLOCK tail; /* tail field */
-static int tail_truncation; /* flag truncation after the tail field */
+static bool tail_truncation; /* flag truncation after the tail field */
static BLOCK before; /* before field */
-static int before_truncation; /* flag truncation before the before field */
+static bool before_truncation; /* flag truncation before the before field */
static BLOCK keyafter; /* keyword-and-after field */
-static int keyafter_truncation; /* flag truncation after the keyafter field */
+static bool keyafter_truncation; /* flag truncation after the keyafter field */
static BLOCK head; /* head field */
-static int head_truncation; /* flag truncation before the head field */
+static bool head_truncation; /* flag truncation before the head field */
static BLOCK reference; /* reference field for input reference mode */
@@ -540,8 +545,8 @@ compare_words (const void *void_first, const void *void_second)
{
#define first ((const WORD *) void_first)
#define second ((const WORD *) void_second)
- int length; /* minimum of two lengths */
- int counter; /* cursor in words */
+ ptrdiff_t length; /* minimum of two lengths */
+ ptrdiff_t counter; /* cursor in words */
int value; /* value of comparison */
length = first->size < second->size ? first->size : second->size;
@@ -567,7 +572,7 @@ compare_words (const void *void_first, const void *void_second)
}
}
- return first->size - second->size;
+ return first->size < second->size ? -1 : first->size > second->size;
#undef first
#undef second
}
@@ -586,21 +591,21 @@ compare_occurs (const void *void_first, const void *void_second)
int value;
value = compare_words (&first->key, &second->key);
- return value == 0 ? first->key.start - second->key.start : value;
+ return (value ? value
+ : first->key.start < second->key.start ? -1
+ : first->key.start > second->key.start);
#undef first
#undef second
}
-/*------------------------------------------------------------.
-| Return !0 if WORD appears in TABLE. Uses a binary search. |
-`------------------------------------------------------------*/
+/* True if WORD appears in TABLE. Uses a binary search. */
-static int _GL_ATTRIBUTE_PURE
+static bool _GL_ATTRIBUTE_PURE
search_table (WORD *word, WORD_TABLE *table)
{
- int lowest; /* current lowest possible index */
- int highest; /* current highest possible index */
- int middle; /* current middle index */
+ ptrdiff_t lowest; /* current lowest possible index */
+ ptrdiff_t highest; /* current highest possible index */
+ ptrdiff_t middle; /* current middle index */
int value; /* value from last comparison */
lowest = 0;
@@ -614,9 +619,9 @@ search_table (WORD *word, WORD_TABLE *table)
else if (value > 0)
lowest = middle + 1;
else
- return 1;
+ return true;
}
- return 0;
+ return false;
}
/*---------------------------------------------------------------------.
@@ -713,14 +718,8 @@ digest_word_file (const char *file_name, WORD_TABLE *table)
if (cursor > word_start)
{
if (table->length == table->alloc)
- {
- if ((SIZE_MAX / sizeof *table->start - 1) / 2 < table->alloc)
- xalloc_die ();
- table->alloc = table->alloc * 2 + 1;
- table->start = xrealloc (table->start,
- table->alloc * sizeof *table->start);
- }
-
+ table->start = x2nrealloc (table->start, &table->alloc,
+ sizeof *table->start);
table->start[table->length].start = word_start;
table->start[table->length].size = cursor - word_start;
table->length++;
@@ -744,13 +743,13 @@ digest_word_file (const char *file_name, WORD_TABLE *table)
`----------------------------------------------------------------------*/
static void
-find_occurs_in_text (size_t file_index)
+find_occurs_in_text (int file_index)
{
char *cursor; /* for scanning the source text */
char *scan; /* for scanning the source text also */
char *line_start; /* start of the current input line */
char *line_scan; /* newlines scanned until this point */
- int reference_length; /* length of reference in input mode */
+ ptrdiff_t reference_length; /* length of reference in input mode */
WORD possible_key; /* possible key, to ease searches */
OCCURS *occurs_cursor; /* current OCCURS under construction */
@@ -946,16 +945,9 @@ find_occurs_in_text (size_t file_index)
where it will be constructed. */
if (number_of_occurs[0] == occurs_alloc[0])
- {
- if ((SIZE_MAX / sizeof *occurs_table[0] - 1) / 2
- < occurs_alloc[0])
- xalloc_die ();
- occurs_alloc[0] = occurs_alloc[0] * 2 + 1;
- occurs_table[0] =
- xrealloc (occurs_table[0],
- occurs_alloc[0] * sizeof *occurs_table[0]);
- }
-
+ occurs_table[0] = x2nrealloc (occurs_table[0],
+ &occurs_alloc[0],
+ sizeof *occurs_table[0]);
occurs_cursor = occurs_table[0] + number_of_occurs[0];
/* Define the reference field, if any. */
@@ -990,8 +982,7 @@ find_occurs_in_text (size_t file_index)
of the reference. The reference position is simply the
value of 'line_start'. */
- occurs_cursor->reference
- = (DELTA) (line_start - possible_key.start);
+ occurs_cursor->reference = line_start - possible_key.start;
if (reference_length > reference_max_width)
reference_max_width = reference_length;
}
@@ -1023,11 +1014,9 @@ find_occurs_in_text (size_t file_index)
`-----------------------------------------*/
static void
-print_spaces (int number)
+print_spaces (ptrdiff_t number)
{
- int counter;
-
- for (counter = number; counter > 0; counter--)
+ for (ptrdiff_t counter = number; counter > 0; counter--)
putchar (' ');
}
@@ -1200,10 +1189,9 @@ print_field (BLOCK field)
static void
fix_output_parameters (void)
{
- size_t file_index; /* index in text input file arrays */
- int line_ordinal; /* line ordinal value for reference */
- char ordinal_string[12]; /* edited line ordinal for reference */
- int reference_width; /* width for the whole reference */
+ int file_index; /* index in text input file arrays */
+ intmax_t line_ordinal; /* line ordinal value for reference */
+ ptrdiff_t reference_width; /* width for the whole reference */
int character; /* character ordinal */
const char *cursor; /* cursor in some constant strings */
@@ -1219,15 +1207,15 @@ fix_output_parameters (void)
line_ordinal = file_line_count[file_index] + 1;
if (file_index > 0)
line_ordinal -= file_line_count[file_index - 1];
- sprintf (ordinal_string, "%d", line_ordinal);
- reference_width = strlen (ordinal_string);
+ char ordinal_string[INT_BUFSIZE_BOUND (intmax_t)];
+ reference_width = sprintf (ordinal_string, "%"PRIdMAX, line_ordinal);
if (input_file_name[file_index])
reference_width += strlen (input_file_name[file_index]);
if (reference_width > reference_max_width)
reference_max_width = reference_width;
}
reference_max_width++;
- reference.start = xmalloc ((size_t) reference_max_width + 1);
+ reference.start = xmalloc (reference_max_width + 1);
}
/* If the reference appears to the left of the output line, reserve some
@@ -1355,14 +1343,14 @@ fix_output_parameters (void)
static void
define_all_fields (OCCURS *occurs)
{
- int tail_max_width; /* allowable width of tail field */
- int head_max_width; /* allowable width of head field */
+ ptrdiff_t tail_max_width; /* allowable width of tail field */
+ ptrdiff_t head_max_width; /* allowable width of head field */
char *cursor; /* running cursor in source text */
char *left_context_start; /* start of left context */
char *right_context_end; /* end of right context */
char *left_field_start; /* conservative start for 'head'/'before' */
const char *file_name; /* file name for reference */
- int line_ordinal; /* line ordinal for reference */
+ intmax_t line_ordinal; /* line ordinal for reference */
const char *buffer_start; /* start of buffered file for this occurs */
const char *buffer_end; /* end of buffered file for this occurs */
@@ -1435,7 +1423,7 @@ define_all_fields (OCCURS *occurs)
before_truncation = cursor > left_context_start;
}
else
- before_truncation = 0;
+ before_truncation = false;
SKIP_WHITE (before.start, buffer_end);
@@ -1468,11 +1456,11 @@ define_all_fields (OCCURS *occurs)
if (tail.end > tail.start)
{
- keyafter_truncation = 0;
+ keyafter_truncation = false;
tail_truncation = truncation_string && tail.end < right_context_end;
}
else
- tail_truncation = 0;
+ tail_truncation = false;
SKIP_WHITE_BACKWARDS (tail.end, tail.start);
}
@@ -1483,7 +1471,7 @@ define_all_fields (OCCURS *occurs)
tail.start = NULL;
tail.end = NULL;
- tail_truncation = 0;
+ tail_truncation = false;
}
/* 'head' could not take more columns than what has been left in the right
@@ -1506,12 +1494,12 @@ define_all_fields (OCCURS *occurs)
if (head.end > head.start)
{
- before_truncation = 0;
+ before_truncation = false;
head_truncation = (truncation_string
&& head.start > left_context_start);
}
else
- head_truncation = 0;
+ head_truncation = false;
SKIP_WHITE (head.start, head.end);
}
@@ -1522,7 +1510,7 @@ define_all_fields (OCCURS *occurs)
head.start = NULL;
head.end = NULL;
- head_truncation = 0;
+ head_truncation = false;
}
if (auto_reference)
@@ -1540,8 +1528,8 @@ define_all_fields (OCCURS *occurs)
if (occurs->file_index > 0)
line_ordinal -= file_line_count[occurs->file_index - 1];
- sprintf (reference.start, "%s:%d", file_name, line_ordinal);
- reference.end = reference.start + strlen (reference.start);
+ char *file_end = stpcpy (reference.start, file_name);
+ reference.end = file_end + sprintf (file_end, ":%"PRIdMAX, line_ordinal);
}
else if (input_reference)
{
@@ -1549,7 +1537,7 @@ define_all_fields (OCCURS *occurs)
/* Reference starts at saved position for reference and extends right
until some white space is met. */
- reference.start = keyafter.start + (DELTA) occurs->reference;
+ reference.start = keyafter.start + occurs->reference;
reference.end = reference.start;
SKIP_NON_WHITE (reference.end, right_context_end);
}
@@ -1753,7 +1741,7 @@ output_one_dumb_line (void)
static void
generate_all_output (void)
{
- size_t occurs_index; /* index of keyword entry being processed */
+ ptrdiff_t occurs_index; /* index of keyword entry being processed */
OCCURS *occurs_cursor; /* current keyword entry being processed */
/* The following assignments are useful to provide default values in case
@@ -1762,11 +1750,11 @@ generate_all_output (void)
tail.start = NULL;
tail.end = NULL;
- tail_truncation = 0;
+ tail_truncation = false;
head.start = NULL;
head.end = NULL;
- head_truncation = 0;
+ head_truncation = false;
/* Loop over all keyword occurrences. */
@@ -1946,12 +1934,12 @@ main (int argc, char **argv)
case 'g':
{
- unsigned long int tmp_ulong;
- if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) != LONGINT_OK
- || ! (0 < tmp_ulong && tmp_ulong <= INT_MAX))
+ intmax_t tmp;
+ if (! (xstrtoimax (optarg, NULL, 0, &tmp, NULL) == LONGINT_OK
+ && 0 < tmp && tmp <= PTRDIFF_MAX))
die (EXIT_FAILURE, 0, _("invalid gap width: %s"),
quote (optarg));
- gap_size = tmp_ulong;
+ gap_size = tmp;
break;
}
@@ -1973,12 +1961,12 @@ main (int argc, char **argv)
case 'w':
{
- unsigned long int tmp_ulong;
- if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) != LONGINT_OK
- || ! (0 < tmp_ulong && tmp_ulong <= INT_MAX))
+ intmax_t tmp;
+ if (! (xstrtoimax (optarg, NULL, 0, &tmp, NULL) == LONGINT_OK
+ && 0 < tmp && tmp <= PTRDIFF_MAX))
die (EXIT_FAILURE, 0, _("invalid line width: %s"),
quote (optarg));
- line_width = tmp_ulong;
+ line_width = tmp;
break;
}
@@ -2045,9 +2033,9 @@ main (int argc, char **argv)
else if (gnu_extensions)
{
number_input_files = argc - optind;
- input_file_name = xmalloc (number_input_files * sizeof *input_file_name);
- file_line_count = xmalloc (number_input_files * sizeof *file_line_count);
- text_buffers = xmalloc (number_input_files * sizeof *text_buffers);
+ input_file_name = xnmalloc (number_input_files, sizeof *input_file_name);
+ file_line_count = xnmalloc (number_input_files, sizeof *file_line_count);
+ text_buffers = xnmalloc (number_input_files, sizeof *text_buffers);
for (file_index = 0; file_index < number_input_files; file_index++)
{
--
2.9.5

View File

@ -1,33 +0,0 @@
From 76be8a7f9eb717b3d47009eb25d39fe7139a2c2d Mon Sep 17 00:00:00 2001
From: Sebastian Kisela <skisela@redhat.com>
Date: Tue, 30 May 2017 09:29:32 +0200
Subject: [PATCH] doc: mention `setpriv --no-new-privs` feature in runcon info
upstream commit: 6ebaf8195000d6d3590a2eac13f13b158e325452
---
doc/coreutils.texi | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 68df075..e16e885 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -16583,7 +16583,14 @@ are interpreted as arguments to the command.
With neither @var{context} nor @var{command}, print the current
security context.
-The program accepts the following options. Also see @ref{Common options}.
+@cindex restricted security context
+@cindex NO_NEW_PRIVS
+Note also the @command{setpriv} command which can be used to set the
+NO_NEW_PRIVS bit using @command{setpriv --no-new-privs runcon ...},
+thus disallowing usage of a security context with more privileges
+than the process would normally have.
+
+@command{runcon} accepts the following options. Also see @ref{Common options}.
@table @samp
--
2.9.4

View File

@ -1,168 +0,0 @@
From ba5fe2d4b8b6a8366f48b1ad1f97fe26c9089b53 Mon Sep 17 00:00:00 2001
From: Sebastian Kisela <skisela@redhat.com>
Date: Wed, 5 Apr 2017 09:40:41 +0200
Subject: [PATCH] tail: revert to polling if a followed directory is replaced
* src/tail.c (tail_forever_inotify): Add the IN_DELETE_SELF flag when
creating watch for the parent directory. After the parent directory
is removed, an event is caught and then we switch from inotify to
polling mode. Till now, inotify has always frozen because it waited for
an event from a watched dir, which has been already deleted and was not
added again.
* tests/tail-2/inotify-dir-recreate.sh: Add a test case.
* tests/local.mk: Reference the new test.
Fixes http://bugs.gnu.org/26363
Reported at https://bugzilla.redhat.com/1283760
Upstream-commit: ba5fe2d4b8b6a8366f48b1ad1f97fe26c9089b53
---
src/tail.c | 22 +++++++++-
tests/local.mk | 1 +
tests/tail-2/inotify-dir-recreate.sh | 82 ++++++++++++++++++++++++++++++++++++
4 files changed, 107 insertions(+), 1 deletion(-)
create mode 100755 tests/tail-2/inotify-dir-recreate.sh
diff --git a/src/tail.c b/src/tail.c
index d1552d4..6328fe0 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -1457,7 +1457,8 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
In that case the same watch descriptor is returned. */
f[i].parent_wd = inotify_add_watch (wd, dirlen ? f[i].name : ".",
(IN_CREATE | IN_DELETE
- | IN_MOVED_TO | IN_ATTRIB));
+ | IN_MOVED_TO | IN_ATTRIB
+ | IN_DELETE_SELF));
f[i].name[dirlen] = prev;
@@ -1628,6 +1629,25 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
ev = void_ev;
evbuf_off += sizeof (*ev) + ev->len;
+ /* If a directory is deleted, IN_DELETE_SELF is emitted
+ with ev->name of length 0.
+ We need to catch it, otherwise it would wait forever,
+ as wd for directory becomes inactive. Revert to polling now. */
+ if ((ev->mask & IN_DELETE_SELF) && ! ev->len)
+ {
+ for (i = 0; i < n_files; i++)
+ {
+ if (ev->wd == f[i].parent_wd)
+ {
+ hash_free (wd_to_name);
+ error (0, 0,
+ _("directory containing watched file was removed"));
+ errno = 0; /* we've already diagnosed enough errno detail. */
+ return true;
+ }
+ }
+ }
+
if (ev->len) /* event on ev->name in watched directory. */
{
size_t j;
diff --git a/tests/local.mk b/tests/local.mk
index 3fe9ba8..e890c9a 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -176,6 +176,7 @@ all_tests = \
tests/tail-2/descriptor-vs-rename.sh \
tests/tail-2/inotify-rotate.sh \
tests/tail-2/inotify-rotate-resources.sh \
+ tests/tail-2/inotify-dir-recreate.sh \
tests/chmod/no-x.sh \
tests/chgrp/basic.sh \
tests/rm/dangling-symlink.sh \
diff --git a/tests/tail-2/inotify-dir-recreate.sh b/tests/tail-2/inotify-dir-recreate.sh
new file mode 100755
index 0000000..eaa8422
--- /dev/null
+++ b/tests/tail-2/inotify-dir-recreate.sh
@@ -0,0 +1,82 @@
+#!/bin/sh
+# Makes sure, inotify will switch to polling mode if directory
+# of the watched file was removed and recreated.
+# (...instead of getting stuck forever)
+
+# Copyright (C) 2006-2017 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ tail
+
+
+# Terminate any background tail process
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
+
+cleanup_fail_ ()
+{
+ warn_ $1
+ cleanup_
+ fail=1
+}
+
+# $check_re - string to be found
+# $check_f - file to be searched
+check_tail_output_ ()
+{
+ local delay="$1"
+ grep $check_re $check_f > /dev/null ||
+ { sleep $delay ; return 1; }
+}
+
+grep_timeout_ ()
+{
+ check_re="$1"
+ check_f="$2"
+ retry_delay_ check_tail_output_ .1 5
+}
+
+# Prepare the file to be watched
+mkdir dir && echo 'inotify' > dir/file || framework_failure_
+
+#tail must print content of the file to stdout, verify
+timeout 60 tail -F dir/file &>out & pid=$!
+grep_timeout_ 'inotify' 'out' ||
+{ cleanup_fail_ 'file to be tailed does not exist'; }
+
+# Remove the directory, should get the message about the deletion
+rm -r dir || framework_failure_
+grep_timeout_ 'polling' 'out' ||
+{ cleanup_fail_ 'tail did not switch to polling mode'; }
+
+# Recreate the dir, must get a message about recreation
+mkdir dir && touch dir/file || framework_failure_
+grep_timeout_ 'appeared' 'out' ||
+{ cleanup_fail_ 'previously removed file did not appear'; }
+
+cleanup_
+
+# Expected result for the whole process
+cat <<\EOF > exp || framework_failure_
+inotify
+tail: 'dir/file' has become inaccessible: No such file or directory
+tail: directory containing watched file was removed
+tail: inotify cannot be used, reverting to polling
+tail: 'dir/file' has appeared; following new file
+EOF
+
+compare exp out || fail=1
+
+Exit $fail
--
2.9.3

View File

@ -1,16 +0,0 @@
-----BEGIN PGP SIGNATURE-----
iQIcBAABAgAGBQJYwOwaAAoJEN9v2XEwYDfZQrUP/RdXj/ug35e+u+VD1ts9/b8n
7JihJmxngEZQAJECNTMbJ7mNj6DhpMY0Jg/Hwg7zJT28T6QDeS1Iuk3Id4uM5eFa
CgHKAZumntSMTkQdNvnCEFEIqu+L8BtBYGcOaw66wAFNFw3jdJUUs2sOST2r46jR
N7aY9oARKJuHfgTZ2BI2zL0Q+poXM1O0k/U+BScE6c139zJsbg+1uM9kGVtJWPkM
EPLFWkbTgjYnt+qEFrDlWL0YFOS42sgR7P1sVfBC1nAu5lwgzPy62OtGv9WCEBhm
3+PRNZ0KLW8CKp06llG/0bG4QwssWs6p/vPwrRGeAg6pKsRNN1ni27AnDThiPgvz
YbBLgU+EZj1HuibvYArHXNKY2+O5ZC3nYU6bdAffl3TAtrGFA1ncZXGiFD5UgOQ2
V9Q38S41FUEwKGtf9tWGCRTxrb4FQ1CDzJglV9vHKetn4mgH/HpEG/q07k4RNW5d
ikfrS0xFxbqtLjlY3UqvtkrFyVQFY093ozsP7fKsq53JAtEWc3YvXR8UCbliU+gV
5qug0REBQafe9EAyH+oq0dzD2BZ3KtFcjtKI/2UzAf3idcyygsHgcEPQObqI8BfD
NscEMjdFY7+Zh5w2shQlyq4xr2aI2nXCX3+AMcS/6Yfg6W6fBvgIjtmXBrQsbWpV
DBcx50TVDa/ERBX1+FI1
=skPR
-----END PGP SIGNATURE-----

16
coreutils-8.28.tar.xz.sig Normal file
View File

@ -0,0 +1,16 @@
-----BEGIN PGP SIGNATURE-----
iQIcBAABAgAGBQJZqhkfAAoJEN9v2XEwYDfZZEQP/REePQxk2OXPSRSyYSaazIeP
gDno1D4tcHXHhvl210ouOEvCGux6tJtHmCQ5Y43Dkt56DJ3Eb9dk2JYrisvcrJhv
3m098YY2hseVLJ7M3jnf9slAXBrS23i+mUWHADeRpFIJZQQz1KEZVb1gsI0FO9Ch
Qp64hBPB4X1Ydxz57KywUpEgBC9Cj0KwWW9L6jIHK+V1izLoI1JslUxHXkyTy9as
WjmDuJp1nMewjbAza//HHNiqote59JewuLcxiA9EdK8jzQZXF+fbRasFO3XEobMl
0WYtN0MwYN2576xSGwTyp7IakFcNHjWciE9SuvPmg/VCLELV6vl4VJXAmv/kQKeE
whVq7kfdzRAKDwUXdXyCqzYSEi1+N+2izJaI4twgExDwm89OApe6aka8UBbqClyz
cn4UmqYMgjwvKXPJtqMUmzEwAzDxuXQJL6Uj5kY8RJLCqBv/eN+YoxODTZz3oDGU
988K6K2Q9QaOGSNJHiBrgddCARuxeRVizbDSi2GcSQdPRbTM4g7YK//KE8LoKdil
ngIeam0vomPJnJqI03U1wGKhxsDqOEEQ3CFch7mQ2S1eWtqeag3arcBVALZUdCzX
hckiSXd0Yuks8AyHb8LH7/3h1BJUWVg/v7iQ2E3UMHAE78Ww28MyppMhy+4U9knU
Dp2VXtxBOJVXJETdVFXY
=7Q/5
-----END PGP SIGNATURE-----

View File

@ -112,7 +112,7 @@ index 8f760db..a7385fd 100644
{
if (posix_format)
diff --git a/tests/df/direct.sh b/tests/df/direct.sh
new file mode 100644
new file mode 100755
index 0000000..8e4cfb8
--- /dev/null
+++ b/tests/df/direct.sh

View File

@ -16,15 +16,15 @@ diff --git a/src/expand-common.c b/src/expand-common.c
index 4657e46..97cbb09 100644
--- a/src/expand-common.c
+++ b/src/expand-common.c
@@ -18,6 +18,7 @@
@@ -19,6 +19,7 @@
#include <assert.h>
#include <stdio.h>
#include <sys/types.h>
+#include <mbfile.h>
#include "system.h"
#include "die.h"
#include "error.h"
@@ -105,6 +106,119 @@ set_extend_size (uintmax_t tabval)
@@ -126,6 +127,119 @@ set_increment_size (uintmax_t tabval)
return ok;
}
@ -171,7 +171,7 @@ diff --git a/src/expand.c b/src/expand.c
index 310b349..4136824 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -105,11 +105,33 @@ expand (void)
@@ -103,11 +103,33 @@ expand (void)
FILE *fp = next_file (NULL);
mb_file_t mbf;
mbf_char_t c;
@ -206,7 +206,7 @@ index 310b349..4136824 100644
while (true)
{
@@ -134,6 +156,27 @@ expand (void)
@@ -132,6 +154,27 @@ expand (void)
if ((mb_iseof (c)) && (fp = next_file (fp)))
{
mbf_init (mbf, fp);

View File

@ -845,7 +845,7 @@ index 98b461c..9990f38 100644
xfields (line);
if (prevline[which - 1])
@@ -567,21 +807,28 @@ prfield (size_t n, struct line const *line)
@@ -563,21 +803,28 @@ prfield (size_t n, struct line const *line)
/* Output all the fields in line, other than the join field. */
@ -877,7 +877,7 @@ index 98b461c..9990f38 100644
prfield (i, line);
}
}
@@ -592,7 +839,6 @@ static void
@@ -588,7 +835,6 @@ static void
prjoin (struct line const *line1, struct line const *line2)
{
const struct outlist *outlist;
@ -885,7 +885,7 @@ index 98b461c..9990f38 100644
size_t field;
struct line const *line;
@@ -626,7 +872,7 @@ prjoin (struct line const *line1, struct line const *line2)
@@ -622,7 +868,7 @@ prjoin (struct line const *line1, struct line const *line2)
o = o->next;
if (o == NULL)
break;
@ -894,7 +894,7 @@ index 98b461c..9990f38 100644
}
putchar (eolchar);
}
@@ -1104,20 +1350,43 @@ main (int argc, char **argv)
@@ -1099,20 +1345,43 @@ main (int argc, char **argv)
case 't':
{
@ -1171,7 +1171,7 @@ index 26f221f..633f50e 100644
use_col_separator = true;
if (optarg)
separator_string (optarg);
@@ -1166,10 +1250,45 @@ getoptnum (const char *n_str, int min, int *num, const char *err)
@@ -1165,10 +1249,45 @@ getoptnum (const char *n_str, int min, int *num, const char *err)
a number. */
static void
@ -1219,7 +1219,7 @@ index 26f221f..633f50e 100644
if (*arg)
{
long int tmp_long;
@@ -1191,6 +1310,11 @@ static void
@@ -1190,6 +1309,11 @@ static void
init_parameters (int number_of_files)
{
int chars_used_by_number = 0;
@ -1231,7 +1231,7 @@ index 26f221f..633f50e 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)
@@ -1227,7 +1351,7 @@ init_parameters (int number_of_files)
else
col_sep_string = column_separator;
@ -1240,7 +1240,7 @@ index 26f221f..633f50e 100644
use_col_separator = true;
}
/* It's rather pointless to define a TAB separator with column
@@ -1258,11 +1382,11 @@ init_parameters (int number_of_files)
@@ -1257,11 +1381,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. */
@ -1254,7 +1254,7 @@ index 26f221f..633f50e 100644
/* The number is part of the column width unless we are
printing files in parallel. */
@@ -1271,7 +1395,7 @@ init_parameters (int number_of_files)
@@ -1270,7 +1394,7 @@ init_parameters (int number_of_files)
}
int sep_chars, useful_chars;
@ -1263,7 +1263,7 @@ index 26f221f..633f50e 100644
sep_chars = INT_MAX;
if (INT_SUBTRACT_WRAPV (chars_per_line - chars_used_by_number, sep_chars,
&useful_chars))
@@ -1294,7 +1418,7 @@ init_parameters (int number_of_files)
@@ -1293,7 +1417,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);
@ -1272,7 +1272,7 @@ index 26f221f..633f50e 100644
}
/* Open the necessary files,
@@ -1402,7 +1526,7 @@ init_funcs (void)
@@ -1399,7 +1523,7 @@ init_funcs (void)
/* Enlarge p->start_position of first column to use the same form of
padding_not_printed with all columns. */
@ -1281,7 +1281,7 @@ index 26f221f..633f50e 100644
/* This loop takes care of all but the rightmost column. */
@@ -1436,7 +1560,7 @@ init_funcs (void)
@@ -1433,7 +1557,7 @@ init_funcs (void)
}
else
{
@ -1290,7 +1290,7 @@ index 26f221f..633f50e 100644
h_next = h + chars_per_column;
}
}
@@ -1727,9 +1851,9 @@ static void
@@ -1724,9 +1848,9 @@ static void
align_column (COLUMN *p)
{
padding_not_printed = p->start_position;
@ -1302,7 +1302,7 @@ index 26f221f..633f50e 100644
padding_not_printed = ANYWHERE;
}
@@ -2004,13 +2128,13 @@ store_char (char c)
@@ -2001,13 +2125,13 @@ store_char (char c)
/* May be too generous. */
buff = X2REALLOC (buff, &buff_allocated);
}
@ -1318,7 +1318,7 @@ index 26f221f..633f50e 100644
char *s;
int num_width;
@@ -2027,22 +2151,24 @@ add_line_number (COLUMN *p)
@@ -2024,22 +2148,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. */
@ -1347,7 +1347,7 @@ index 26f221f..633f50e 100644
output_position = POS_AFTER_TAB (chars_per_output_tab,
output_position);
}
@@ -2203,7 +2329,7 @@ print_white_space (void)
@@ -2198,7 +2324,7 @@ print_white_space (void)
while (goal - h_old > 1
&& (h_new = POS_AFTER_TAB (chars_per_output_tab, h_old)) <= goal)
{
@ -1356,7 +1356,7 @@ index 26f221f..633f50e 100644
h_old = h_new;
}
while (++h_old <= goal)
@@ -2223,6 +2349,7 @@ print_sep_string (void)
@@ -2218,6 +2344,7 @@ print_sep_string (void)
{
char const *s = col_sep_string;
int l = col_sep_length;
@ -1364,7 +1364,7 @@ index 26f221f..633f50e 100644
if (separators_not_printed <= 0)
{
@@ -2234,6 +2361,7 @@ print_sep_string (void)
@@ -2229,6 +2356,7 @@ print_sep_string (void)
{
for (; separators_not_printed > 0; --separators_not_printed)
{
@ -1372,7 +1372,7 @@ index 26f221f..633f50e 100644
while (l-- > 0)
{
/* 3 types of sep_strings: spaces only, spaces and chars,
@@ -2247,12 +2375,15 @@ print_sep_string (void)
@@ -2242,12 +2370,15 @@ print_sep_string (void)
}
else
{
@ -1389,7 +1389,7 @@ index 26f221f..633f50e 100644
/* sep_string ends with some spaces */
if (spaces_not_printed > 0)
print_white_space ();
@@ -2280,7 +2411,7 @@ print_clump (COLUMN *p, int n, char *clump)
@@ -2275,7 +2406,7 @@ print_clump (COLUMN *p, int n, char *clump)
required number of tabs and spaces. */
static void
@ -1398,7 +1398,7 @@ index 26f221f..633f50e 100644
{
if (tabify_output)
{
@@ -2304,6 +2435,74 @@ print_char (char c)
@@ -2299,6 +2430,74 @@ print_char (char c)
putchar (c);
}
@ -1473,7 +1473,7 @@ index 26f221f..633f50e 100644
/* Skip to page PAGE before printing.
PAGE may be larger than total number of pages. */
@@ -2483,9 +2682,9 @@ read_line (COLUMN *p)
@@ -2476,9 +2675,9 @@ read_line (COLUMN *p)
align_empty_cols = false;
}
@ -1485,8 +1485,8 @@ index 26f221f..633f50e 100644
padding_not_printed = ANYWHERE;
}
@@ -2555,7 +2754,7 @@ print_stored (COLUMN *p)
int i;
@@ -2547,7 +2746,7 @@ print_stored (COLUMN *p)
COLUMN *q;
int line = p->current_line++;
- char *first = &buff[line_vector[line]];
@ -1494,7 +1494,7 @@ index 26f221f..633f50e 100644
/* FIXME
UMR: Uninitialized memory read:
* This is occurring while in:
@@ -2567,7 +2766,7 @@ print_stored (COLUMN *p)
@@ -2559,7 +2758,7 @@ print_stored (COLUMN *p)
xmalloc [xmalloc.c:94]
init_store_cols [pr.c:1648]
*/
@ -1503,7 +1503,7 @@ index 26f221f..633f50e 100644
pad_vertically = true;
@@ -2586,9 +2785,9 @@ print_stored (COLUMN *p)
@@ -2579,9 +2778,9 @@ print_stored (COLUMN *p)
}
}
@ -1515,7 +1515,7 @@ index 26f221f..633f50e 100644
padding_not_printed = ANYWHERE;
}
@@ -2601,8 +2800,8 @@ print_stored (COLUMN *p)
@@ -2594,8 +2793,8 @@ print_stored (COLUMN *p)
if (spaces_not_printed == 0)
{
output_position = p->start_position + end_vector[line];
@ -1526,7 +1526,7 @@ index 26f221f..633f50e 100644
}
return true;
@@ -2621,7 +2820,7 @@ print_stored (COLUMN *p)
@@ -2614,7 +2813,7 @@ print_stored (COLUMN *p)
number of characters is 1.) */
static int
@ -1535,7 +1535,7 @@ index 26f221f..633f50e 100644
{
unsigned char uc = c;
char *s = clump_buff;
@@ -2631,10 +2830,10 @@ char_to_clump (char c)
@@ -2624,10 +2823,10 @@ char_to_clump (char c)
int chars;
int chars_per_c = 8;
@ -1548,7 +1548,7 @@ index 26f221f..633f50e 100644
{
width = TAB_WIDTH (chars_per_c, input_position);
@@ -2715,6 +2914,164 @@ char_to_clump (char c)
@@ -2708,6 +2907,164 @@ char_to_clump (char c)
return chars;
}
@ -1732,7 +1732,7 @@ index 6d2eec5..f189a0d 100644
#include "system.h"
#include "argmatch.h"
#include "die.h"
@@ -165,14 +173,39 @@ static int decimal_point;
@@ -169,14 +177,39 @@ static int decimal_point;
/* Thousands separator; if -1, then there isn't one. */
static int thousands_sep;
@ -1773,7 +1773,7 @@ index 6d2eec5..f189a0d 100644
/* The kind of blanks for '-b' to skip in various options. */
enum blanktype { bl_start, bl_end, bl_both };
@@ -346,13 +379,11 @@ static bool reverse;
@@ -350,13 +383,11 @@ static bool reverse;
they were read if all keys compare equal. */
static bool stable;
@ -1790,7 +1790,7 @@ index 6d2eec5..f189a0d 100644
/* Flag to remove consecutive duplicate lines from the output.
Only the last of a sequence of equal lines will be output. */
@@ -811,6 +842,46 @@ reap_all (void)
@@ -814,6 +845,46 @@ reap_all (void)
reap (-1);
}
@ -1837,7 +1837,7 @@ index 6d2eec5..f189a0d 100644
/* Clean up any remaining temporary files. */
static void
@@ -1255,7 +1326,7 @@ zaptemp (char const *name)
@@ -1264,7 +1335,7 @@ zaptemp (char const *name)
free (node);
}
@ -1846,7 +1846,7 @@ index 6d2eec5..f189a0d 100644
static int
struct_month_cmp (void const *m1, void const *m2)
@@ -1270,7 +1341,7 @@ struct_month_cmp (void const *m1, void const *m2)
@@ -1279,7 +1350,7 @@ struct_month_cmp (void const *m1, void const *m2)
/* Initialize the character class tables. */
static void
@ -1855,7 +1855,7 @@ index 6d2eec5..f189a0d 100644
{
size_t i;
@@ -1282,7 +1353,7 @@ inittables (void)
@@ -1291,7 +1362,7 @@ inittables (void)
fold_toupper[i] = toupper (i);
}
@ -1864,7 +1864,7 @@ index 6d2eec5..f189a0d 100644
/* If we're not in the "C" locale, read different names for months. */
if (hard_LC_TIME)
{
@@ -1364,6 +1435,84 @@ specify_nmerge (int oi, char c, char const *s)
@@ -1373,6 +1444,84 @@ specify_nmerge (int oi, char c, char const *s)
xstrtol_fatal (e, oi, c, long_options, s);
}
@ -1949,7 +1949,7 @@ index 6d2eec5..f189a0d 100644
/* Specify the amount of main memory to use when sorting. */
static void
specify_sort_size (int oi, char c, char const *s)
@@ -1597,7 +1746,7 @@ buffer_linelim (struct buffer const *buf)
@@ -1604,7 +1753,7 @@ buffer_linelim (struct buffer const *buf)
by KEY in LINE. */
static char *
@ -1958,7 +1958,7 @@ index 6d2eec5..f189a0d 100644
{
char *ptr = line->text, *lim = ptr + line->length - 1;
size_t sword = key->sword;
@@ -1606,10 +1755,10 @@ begfield (struct line const *line, struct keyfield const *key)
@@ -1613,10 +1762,10 @@ begfield (struct line const *line, struct keyfield const *key)
/* The leading field separator itself is included in a field when -t
is absent. */
@ -1971,7 +1971,7 @@ index 6d2eec5..f189a0d 100644
++ptr;
if (ptr < lim)
++ptr;
@@ -1635,11 +1784,70 @@ begfield (struct line const *line, struct keyfield const *key)
@@ -1642,11 +1791,70 @@ begfield (struct line const *line, struct keyfield const *key)
return ptr;
}
@ -2043,7 +2043,7 @@ index 6d2eec5..f189a0d 100644
{
char *ptr = line->text, *lim = ptr + line->length - 1;
size_t eword = key->eword, echar = key->echar;
@@ -1654,10 +1862,10 @@ limfield (struct line const *line, struct keyfield const *key)
@@ -1661,10 +1869,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. */
@ -2056,7 +2056,7 @@ index 6d2eec5..f189a0d 100644
++ptr;
if (ptr < lim && (eword || echar))
++ptr;
@@ -1703,10 +1911,10 @@ limfield (struct line const *line, struct keyfield const *key)
@@ -1710,10 +1918,10 @@ limfield (struct line const *line, struct keyfield const *key)
*/
/* Make LIM point to the end of (one byte past) the current field. */
@ -2069,7 +2069,7 @@ index 6d2eec5..f189a0d 100644
if (newlim)
lim = newlim;
}
@@ -1737,6 +1945,130 @@ limfield (struct line const *line, struct keyfield const *key)
@@ -1744,6 +1952,130 @@ limfield (struct line const *line, struct keyfield const *key)
return ptr;
}
@ -2200,7 +2200,7 @@ index 6d2eec5..f189a0d 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
@@ -1823,8 +2155,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file)
@@ -1830,8 +2162,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file)
else
{
if (key->skipsblanks)
@ -2225,7 +2225,7 @@ index 6d2eec5..f189a0d 100644
line->keybeg = line_start;
}
}
@@ -1974,7 +2320,7 @@ human_numcompare (char const *a, char const *b)
@@ -1981,7 +2327,7 @@ human_numcompare (char const *a, char const *b)
hideously fast. */
static int
@ -2234,7 +2234,7 @@ index 6d2eec5..f189a0d 100644
{
while (blanks[to_uchar (*a)])
a++;
@@ -1984,6 +2330,25 @@ numcompare (char const *a, char const *b)
@@ -1991,6 +2337,25 @@ numcompare (char const *a, char const *b)
return strnumcmp (a, b, decimal_point, thousands_sep);
}
@ -2260,7 +2260,7 @@ index 6d2eec5..f189a0d 100644
/* 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 once
@@ -2034,7 +2399,7 @@ general_numcompare (char const *sa, char const *sb)
@@ -2041,7 +2406,7 @@ general_numcompare (char const *sa, char const *sb)
Return 0 if the name in S is not recognized. */
static int
@ -2269,7 +2269,7 @@ index 6d2eec5..f189a0d 100644
{
size_t lo = 0;
size_t hi = MONTHS_PER_YEAR;
@@ -2310,15 +2675,14 @@ debug_key (struct line const *line, struct keyfield const *key)
@@ -2317,15 +2682,14 @@ debug_key (struct line const *line, struct keyfield const *key)
char saved = *lim;
*lim = '\0';
@ -2287,7 +2287,7 @@ index 6d2eec5..f189a0d 100644
else if (key->general_numeric)
ignore_value (strtold (beg, &tighter_lim));
else if (key->numeric || key->human_numeric)
@@ -2452,7 +2816,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
@@ -2459,7 +2823,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 */
@ -2296,7 +2296,7 @@ index 6d2eec5..f189a0d 100644
&& ((!key->skipsblanks && !implicit_skip)
|| (!key->skipsblanks && key->schar)
|| (!key->skipeblanks && key->echar)))
@@ -2510,11 +2874,87 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
@@ -2517,11 +2881,87 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
error (0, 0, _("option '-r' only applies to last-resort comparison"));
}
@ -2385,7 +2385,7 @@ index 6d2eec5..f189a0d 100644
{
struct keyfield *key = keylist;
@@ -2599,7 +3039,7 @@ keycompare (struct line const *a, struct line const *b)
@@ -2606,7 +3046,7 @@ keycompare (struct line const *a, struct line const *b)
else if (key->human_numeric)
diff = human_numcompare (ta, tb);
else if (key->month)
@ -2394,7 +2394,7 @@ index 6d2eec5..f189a0d 100644
else if (key->random)
diff = compare_random (ta, tlena, tb, tlenb);
else if (key->version)
@@ -2715,6 +3155,211 @@ keycompare (struct line const *a, struct line const *b)
@@ -2722,6 +3162,211 @@ keycompare (struct line const *a, struct line const *b)
return key->reverse ? -diff : diff;
}
@ -2606,16 +2606,16 @@ index 6d2eec5..f189a0d 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. */
@@ -2742,7 +3387,7 @@ compare (struct line const *a, struct line const *b)
@@ -2749,7 +3394,7 @@ compare (struct line const *a, struct line const *b)
diff = - NONZERO (blen);
else if (blen == 0)
diff = 1;
- else if (hard_LC_COLLATE)
+ else if (hard_LC_COLLATE && !folding)
{
/* Note xmemcoll0 is a performance enhancement as
/* xmemcoll0 is a performance enhancement as
it will not unconditionally write '\0' after the
@@ -4139,6 +4784,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype)
@@ -4144,6 +4789,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype)
break;
case 'f':
key->translate = fold_toupper;
@ -2623,7 +2623,7 @@ index 6d2eec5..f189a0d 100644
break;
case 'g':
key->general_numeric = true;
@@ -4218,7 +4864,7 @@ main (int argc, char **argv)
@@ -4223,7 +4869,7 @@ main (int argc, char **argv)
initialize_exit_failure (SORT_FAILURE);
hard_LC_COLLATE = hard_locale (LC_COLLATE);
@ -2632,7 +2632,7 @@ index 6d2eec5..f189a0d 100644
hard_LC_TIME = hard_locale (LC_TIME);
#endif
@@ -4239,6 +4885,29 @@ main (int argc, char **argv)
@@ -4244,6 +4890,29 @@ main (int argc, char **argv)
thousands_sep = -1;
}
@ -2662,7 +2662,7 @@ index 6d2eec5..f189a0d 100644
have_read_stdin = false;
inittables ();
@@ -4513,13 +5182,34 @@ main (int argc, char **argv)
@@ -4518,13 +5187,34 @@ main (int argc, char **argv)
case 't':
{
@ -2701,7 +2701,7 @@ index 6d2eec5..f189a0d 100644
else
{
/* Provoke with 'sort -txx'. Complain about
@@ -4530,9 +5220,11 @@ main (int argc, char **argv)
@@ -4535,9 +5225,11 @@ main (int argc, char **argv)
quote (optarg));
}
}
@ -2715,7 +2715,7 @@ index 6d2eec5..f189a0d 100644
}
break;
@@ -4770,12 +5462,10 @@ main (int argc, char **argv)
@@ -4765,12 +5457,10 @@ main (int argc, char **argv)
sort (files, nfiles, outfile, nthreads);
}
@ -3119,7 +3119,7 @@ index 87a0c93..9f755d9 100644
skip_fields = 0;
check_chars = SIZE_MAX;
diff --git a/tests/i18n/sort.sh b/tests/i18n/sort.sh
new file mode 100644
new file mode 100755
index 0000000..26c95de
--- /dev/null
+++ b/tests/i18n/sort.sh
@ -3157,7 +3157,7 @@ diff --git a/tests/local.mk b/tests/local.mk
index 568944e..192f776 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -352,6 +352,8 @@ all_tests = \
@@ -358,6 +358,8 @@ all_tests = \
tests/misc/sort-discrim.sh \
tests/misc/sort-files0-from.pl \
tests/misc/sort-float.sh \
@ -3212,8 +3212,8 @@ index 8a9cad1..9293e39 100755
my @Tests =
(
['t1', '--tabs=3', {IN=>"a\tb"}, {OUT=>"a b"}],
@@ -152,6 +161,8 @@ my @Tests =
['trail9', '--tab=1,2 -t/5',{IN=>"\ta\tb\tc"}, {OUT=>" a b c"}],
@@ -168,6 +177,8 @@ my @Tests =
# Test errors
+ # FIXME: The following tests contain quoting specific to LC_MESSAGES
@ -3221,7 +3221,7 @@ index 8a9cad1..9293e39 100755
['e1', '--tabs="a"', {IN=>''}, {OUT=>''}, {EXIT=>1},
{ERR => "$prog: tab size contains invalid character(s): 'a'\n"}],
['e2', "-t $UINTMAX_OFLOW", {IN=>''}, {OUT=>''}, {EXIT=>1},
@@ -168,6 +179,37 @@ my @Tests =
@@ -184,6 +195,37 @@ my @Tests =
{ERR => "$prog: '/' specifier not at start of number: '/'\n"}],
);
@ -3403,7 +3403,7 @@ index 4d399d8..07f2823 100755
my $verbose = $ENV{VERBOSE};
diff --git a/tests/misc/sort-mb-tests.sh b/tests/misc/sort-mb-tests.sh
new file mode 100644
new file mode 100755
index 0000000..11836ba
--- /dev/null
+++ b/tests/misc/sort-mb-tests.sh

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 8.27
Release: 16%{?dist}
Version: 8.28
Release: 1%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: https://www.gnu.org/software/coreutils/
@ -13,21 +13,6 @@ Source106: coreutils-colorls.csh
# do not make coreutils-single depend on /usr/bin/coreutils
%global __requires_exclude ^%{_bindir}/coreutils$
# upstream patches
Patch1: coreutils-8.27-date-debug-test.patch
# date, touch: fix out-of-bounds write via large TZ variable (CVE-2017-7476)
Patch2: coreutils-8.27-CVE-2017-7476.patch
# tail: revert to polling if a followed directory is replaced (#1283760)
Patch3: coreutils-8.27-tail-inotify-recreate.patch
# doc: mention `setpriv --no-new-privs` feature in runcon info
Patch4: coreutils-8.27-runcon-doc.patch
# ptx: fix a possible crash caused by integer overflow (#1482445)
Patch5: coreutils-8.27-ptx-int-overflow.patch
# disable the test-lock gnulib test prone to deadlock
Patch100: coreutils-8.26-test-lock.patch
@ -296,6 +281,9 @@ fi
%license COPYING
%changelog
* Mon Sep 04 2017 Kamil Dudka <kdudka@redhat.com> - 8.28-1
- new upstream release 8.28
* Tue Aug 22 2017 Ville Skyttä <ville.skytta@iki.fi> - 8.27-16
- Own the %%{_libexecdir}/coreutils dir

View File

@ -1 +1 @@
SHA512 (coreutils-8.27.tar.xz) = abf3280aaa54e9bd5851df0eda2af1de1017ca174633e52d1e592455d46ea0e99812dda46d2f320e979553cef271485d8818c595bba6ed31264511a511c93679
SHA512 (coreutils-8.28.tar.xz) = 1e592d0dd03b9227bf92af9a82bed6dc3bcbee46e984c7fb09833dea0962e86b309aa34d5e43823b73d4522c066bfa5cdc8ec694aa190910fb246ff32ceb63a1