Compare commits
11 Commits
562babab47
...
7855836c7e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7855836c7e | ||
|
|
3a1eeb11d5 | ||
|
|
be5d01d870 | ||
|
|
472d1dba3a | ||
|
|
4440d39338 | ||
|
|
3e3761cbac | ||
|
|
a8fd4479f1 | ||
|
|
f6cd85537a | ||
|
|
e43fc93428 | ||
|
|
044c5d4801 | ||
|
|
fbf3f4b4d7 |
55
backport--Improve-support-for-memory-leak-detection.patch
Normal file
55
backport--Improve-support-for-memory-leak-detection.patch
Normal file
@ -0,0 +1,55 @@
|
||||
From 312b793db6f549a3d4036b5d0ed2265c451ede15 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Gruenbacher <agruen@gnu.org>
|
||||
Date: Thu, 27 Jun 2019 11:02:02 +0200
|
||||
Subject: [PATCH] Improve support for memory leak detection
|
||||
|
||||
When building with the address sanitizer on, free some more resources before
|
||||
exiting. (This is unnecessary when not looking for memory leaks.)
|
||||
* src/patch.c (init_files_to_delete): Add dispose function for freeing
|
||||
filenames.
|
||||
|
||||
Signed-off-by: Xibo.Wang <wangxb12@chinatelecom.cn>
|
||||
---
|
||||
src/patch.c | 16 +++++++++++++++-
|
||||
1 file changed, 15 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/patch.c b/src/patch.c
|
||||
index 99a5904..e57cf19 100644
|
||||
--- a/src/patch.c
|
||||
+++ b/src/patch.c
|
||||
@@ -36,6 +36,10 @@
|
||||
#include <minmax.h>
|
||||
#include <safe.h>
|
||||
|
||||
+#ifdef __SANITIZE_ADDRESS__
|
||||
+# define FREE_BEFORE_EXIT
|
||||
+#endif
|
||||
+
|
||||
/* procedures */
|
||||
|
||||
static FILE *create_output_file (char const *, int);
|
||||
@@ -1777,10 +1781,20 @@ struct file_to_delete {
|
||||
|
||||
static gl_list_t files_to_delete;
|
||||
|
||||
+#ifdef FREE_BEFORE_EXIT
|
||||
+void dispose_file_to_delete (const void *elt)
|
||||
+{
|
||||
+ free ((void *) elt);
|
||||
+}
|
||||
+#else
|
||||
+#define dispose_file_to_delete NULL
|
||||
+#endif
|
||||
+
|
||||
static void
|
||||
init_files_to_delete (void)
|
||||
{
|
||||
- files_to_delete = gl_list_create_empty (GL_LINKED_LIST, NULL, NULL, NULL, true);
|
||||
+ files_to_delete = gl_list_create_empty (GL_LINKED_LIST, NULL, NULL,
|
||||
+ dispose_file_to_delete, true);
|
||||
}
|
||||
|
||||
static void
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
53
backport-Abort-when-cleaning-up-fails.patch
Normal file
53
backport-Abort-when-cleaning-up-fails.patch
Normal file
@ -0,0 +1,53 @@
|
||||
From b5c17c6c6591e62173197f97d3113862bf23bd4d Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Gruenbacher <agruen@gnu.org>
|
||||
Date: Fri, 28 Jun 2019 00:30:25 +0200
|
||||
Subject: [PATCH 2/8] Abort when cleaning up fails
|
||||
|
||||
When a fatal error triggers during cleanup, another attempt will be made to
|
||||
clean up, which will likely lead to the same fatal error. So instead, bail out
|
||||
when that happens.
|
||||
src/patch.c (cleanup): Bail out when called recursively.
|
||||
(main): There is no need to call output_files() before cleanup() as cleanup()
|
||||
already does that.
|
||||
|
||||
Signed-off-by: Xibo.Wang <wangxb12@chinatelecom.cn>
|
||||
---
|
||||
src/patch.c | 8 ++++++--
|
||||
1 file changed, 6 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/patch.c b/src/patch.c
|
||||
index e57cf19..1e1915d 100644
|
||||
--- a/src/patch.c
|
||||
+++ b/src/patch.c
|
||||
@@ -685,7 +685,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
if (outstate.ofp && (ferror (outstate.ofp) || fclose (outstate.ofp) != 0))
|
||||
write_fatal ();
|
||||
- output_files (NULL);
|
||||
cleanup ();
|
||||
delete_files ();
|
||||
if (somefailed)
|
||||
@@ -1991,7 +1990,6 @@ void
|
||||
fatal_exit (int sig)
|
||||
{
|
||||
cleanup ();
|
||||
-
|
||||
if (sig)
|
||||
exit_with_signal (sig);
|
||||
|
||||
@@ -2011,6 +2009,12 @@ remove_if_needed (char const *name, bool *needs_removal)
|
||||
static void
|
||||
cleanup (void)
|
||||
{
|
||||
+ static bool already_cleaning_up;
|
||||
+
|
||||
+ if (already_cleaning_up)
|
||||
+ return;
|
||||
+ already_cleaning_up = true;
|
||||
+
|
||||
remove_if_needed (TMPINNAME, &TMPINNAME_needs_removal);
|
||||
remove_if_needed (TMPOUTNAME, &TMPOUTNAME_needs_removal);
|
||||
remove_if_needed (TMPPATNAME, &TMPPATNAME_needs_removal);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -0,0 +1,132 @@
|
||||
From 3a4a357daa920361d709bbc4cf43865dff769112 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Gruenbacher <agruen@gnu.org>
|
||||
Date: Tue, 30 Jul 2019 12:10:19 +0200
|
||||
Subject: [PATCH 6/8] Add missing-section tests to context-format test case
|
||||
|
||||
* tests/context-format: Add tests with a missing pattern and a missing
|
||||
replacement section in a hunk. Patch should fill in the missing
|
||||
sections from the existing sections.
|
||||
|
||||
Signed-off-by: Xibo.Wang <wangxb12@chinatelecom.cn>
|
||||
---
|
||||
tests/context-format | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 84 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/tests/context-format b/tests/context-format
|
||||
index 8143448..b3276ff 100644
|
||||
--- a/tests/context-format
|
||||
+++ b/tests/context-format
|
||||
@@ -11,6 +11,46 @@ use_tmpdir
|
||||
|
||||
# ==============================================================
|
||||
|
||||
+printf "%s\n" 1 2 4 5 > a
|
||||
+cat > ab.diff <<EOF
|
||||
+*** a
|
||||
+--- b
|
||||
+***************
|
||||
+*** 1,4 ****
|
||||
+--- 1,5 ----
|
||||
+ 1
|
||||
+ 2
|
||||
++ 3
|
||||
+ 4
|
||||
+ 5
|
||||
+EOF
|
||||
+
|
||||
+check 'patch < ab.diff' <<EOF
|
||||
+patching file a
|
||||
+EOF
|
||||
+
|
||||
+printf "%s\n" 1 2 3 4 5 > a
|
||||
+cat > ab.diff <<EOF
|
||||
+*** a
|
||||
+--- b
|
||||
+***************
|
||||
+*** 1,5 ****
|
||||
+ 1
|
||||
+ 2
|
||||
+- 3
|
||||
+ 4
|
||||
+ 5
|
||||
+--- 1,4 ----
|
||||
+EOF
|
||||
+
|
||||
+check 'patch < ab.diff' <<EOF
|
||||
+patching file a
|
||||
+EOF
|
||||
+
|
||||
+# --------------------------------------------------------------
|
||||
+
|
||||
+printf "%s\n" a a a a a b a a a a a > a
|
||||
+
|
||||
cat > ab.diff <<EOF
|
||||
*** a
|
||||
--- b
|
||||
@@ -20,11 +60,33 @@ cat > ab.diff <<EOF
|
||||
--- 5 ----
|
||||
EOF
|
||||
|
||||
-printf "%s\n" a a a a a b a a a a a > a
|
||||
check 'patch < ab.diff' <<EOF
|
||||
patching file a
|
||||
EOF
|
||||
|
||||
+check 'echo `cat a`' <<EOF
|
||||
+a a a a a a a a a a
|
||||
+EOF
|
||||
+
|
||||
+cat > ba.diff <<EOF
|
||||
+*** b
|
||||
+--- a
|
||||
+***************
|
||||
+*** 5 ****
|
||||
+--- 6 ----
|
||||
++ b
|
||||
+EOF
|
||||
+
|
||||
+check 'patch < ba.diff' <<EOF
|
||||
+patching file a
|
||||
+EOF
|
||||
+
|
||||
+check 'echo `cat a`' <<EOF
|
||||
+a a a a a b a a a a a
|
||||
+EOF
|
||||
+
|
||||
+printf "%s\n" a a a a a a a a a a b > a
|
||||
+
|
||||
cat > ab.diff <<EOF
|
||||
*** a
|
||||
--- b
|
||||
@@ -34,7 +96,27 @@ cat > ab.diff <<EOF
|
||||
--- 10 ----
|
||||
EOF
|
||||
|
||||
-printf "%s\n" a a a a a a a a a a b > a
|
||||
check 'patch < ab.diff' <<EOF
|
||||
patching file a
|
||||
EOF
|
||||
+
|
||||
+check 'echo `cat a`' <<EOF
|
||||
+a a a a a a a a a a
|
||||
+EOF
|
||||
+
|
||||
+cat > ba.diff <<EOF
|
||||
+*** b
|
||||
+--- a
|
||||
+***************
|
||||
+*** 10 ****
|
||||
+--- 11 ----
|
||||
++ b
|
||||
+EOF
|
||||
+
|
||||
+check 'patch < ba.diff' <<EOF
|
||||
+patching file a
|
||||
+EOF
|
||||
+
|
||||
+check 'echo `cat a`' <<EOF
|
||||
+a a a a a a a a a a b
|
||||
+EOF
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
From 46136e6440f78b4a21eaeaeabef2b4fcb482c158 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Gruenbacher <agruen@gnu.org>
|
||||
Date: Mon, 15 Jul 2019 19:10:02 +0200
|
||||
Subject: [PATCH 4/8] Avoid invalid memory access in context format diffs
|
||||
|
||||
* src/pch.c (another_hunk): Avoid invalid memory access in context format
|
||||
diffs.
|
||||
|
||||
Signed-off-by: Xibo.Wang <wangxb12@chinatelecom.cn>
|
||||
---
|
||||
src/pch.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/src/pch.c b/src/pch.c
|
||||
index aa0caf4..87e6f93 100644
|
||||
--- a/src/pch.c
|
||||
+++ b/src/pch.c
|
||||
@@ -1335,6 +1335,7 @@ another_hunk (enum diff difftype, bool rev)
|
||||
ptrn_prefix_context = context;
|
||||
ptrn_suffix_context = context;
|
||||
if (repl_beginning
|
||||
+ || p_end <= 0
|
||||
|| (p_end
|
||||
!= p_ptrn_lines + 1 + (p_Char[p_end - 1] == '\n')))
|
||||
{
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
32
backport-CVE-2018-17942.patch
Normal file
32
backport-CVE-2018-17942.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 278b4175c9d7dd47c1a3071554aac02add3b3c35 Mon Sep 17 00:00:00 2001
|
||||
From: Bruno Haible <bruno@clisp.org>
|
||||
Date: Sun, 23 Sep 2018 14:13:52 +0200
|
||||
Subject: vasnprintf: Fix heap memory overrun bug.
|
||||
|
||||
Reported by Ben Pfaff <blp@cs.stanford.edu> in
|
||||
<https://lists.gnu.org/archive/html/bug-gnulib/2018-09/msg00107.html>.
|
||||
|
||||
* lib/vasnprintf.c (convert_to_decimal): Allocate one more byte of
|
||||
memory.
|
||||
---
|
||||
lib/vasnprintf.c | 4 +++-
|
||||
1 files changed, 3 insertions(+), 1 deletions(-)
|
||||
|
||||
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
|
||||
index 56ffbe3..30d021b 100644
|
||||
--- a/lib/vasnprintf.c
|
||||
+++ b/lib/vasnprintf.c
|
||||
@@ -860,7 +860,9 @@ convert_to_decimal (mpn_t a, size_t extra_zeroes)
|
||||
size_t a_len = a.nlimbs;
|
||||
/* 0.03345 is slightly larger than log(2)/(9*log(10)). */
|
||||
size_t c_len = 9 * ((size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1);
|
||||
- char *c_ptr = (char *) malloc (xsum (c_len, extra_zeroes));
|
||||
+ /* We need extra_zeroes bytes for zeroes, followed by c_len bytes for the
|
||||
+ digits of a, followed by 1 byte for the terminating NUL. */
|
||||
+ char *c_ptr = (char *) malloc (xsum (xsum (extra_zeroes, c_len), 1));
|
||||
if (c_ptr != NULL)
|
||||
{
|
||||
char *d_ptr = c_ptr;
|
||||
--
|
||||
cgit v1.1
|
||||
|
||||
@ -0,0 +1,91 @@
|
||||
From 2523dced822caae56f24eff4899c6307e1844df6 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Gruenbacher <agruen@gnu.org>
|
||||
Date: Thu, 27 Jun 2019 11:10:43 +0200
|
||||
Subject: [PATCH 3/8] Don't crash when RLIMIT_NOFILE is set to RLIM_INFINITY
|
||||
|
||||
* src/safe.c (min_cached_fds): Define minimum number of cached dir file
|
||||
descriptors.
|
||||
(max_cached_fds): Change type to rlim_t to allow storing RLIM_INFINITY.
|
||||
(init_dirfd_cache): Set max_cached_fds to RLIM_INFINITY when RLIMIT_NOFILE is
|
||||
RLIM_INFINITY. Set the initial hash table size to min_cached_fds, independent
|
||||
of RLIMIT_NOFILE: patches commonly only affect one or a few files, so a small
|
||||
hash table will usually suffice; if needed, the hash table will grow.
|
||||
(insert_cached_dirfd): Don't shrink the cache when max_cached_fds is
|
||||
RLIM_INFINITY.
|
||||
|
||||
Signed-off-by: Xibo.Wang <wangxb12@chinatelecom.cn>
|
||||
---
|
||||
src/safe.c | 36 +++++++++++++++++++++++-------------
|
||||
1 file changed, 23 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/src/safe.c b/src/safe.c
|
||||
index 5a7202f..f147b0e 100644
|
||||
--- a/src/safe.c
|
||||
+++ b/src/safe.c
|
||||
@@ -67,7 +67,8 @@ struct cached_dirfd {
|
||||
};
|
||||
|
||||
static Hash_table *cached_dirfds = NULL;
|
||||
-static size_t max_cached_fds;
|
||||
+static rlim_t min_cached_fds = 8;
|
||||
+static rlim_t max_cached_fds;
|
||||
LIST_HEAD (lru_list);
|
||||
|
||||
static size_t hash_cached_dirfd (const void *entry, size_t table_size)
|
||||
@@ -98,11 +99,17 @@ static void init_dirfd_cache (void)
|
||||
{
|
||||
struct rlimit nofile;
|
||||
|
||||
- max_cached_fds = 8;
|
||||
if (getrlimit (RLIMIT_NOFILE, &nofile) == 0)
|
||||
- max_cached_fds = MAX (nofile.rlim_cur / 4, max_cached_fds);
|
||||
+ {
|
||||
+ if (nofile.rlim_cur == RLIM_INFINITY)
|
||||
+ max_cached_fds = RLIM_INFINITY;
|
||||
+ else
|
||||
+ max_cached_fds = MAX (nofile.rlim_cur / 4, min_cached_fds);
|
||||
+ }
|
||||
+ else
|
||||
+ max_cached_fds = min_cached_fds;
|
||||
|
||||
- cached_dirfds = hash_initialize (max_cached_fds,
|
||||
+ cached_dirfds = hash_initialize (min_cached_fds,
|
||||
NULL,
|
||||
hash_cached_dirfd,
|
||||
compare_cached_dirfds,
|
||||
@@ -148,20 +155,23 @@ static void insert_cached_dirfd (struct cached_dirfd *entry, int keepfd)
|
||||
if (cached_dirfds == NULL)
|
||||
init_dirfd_cache ();
|
||||
|
||||
- /* Trim off the least recently used entries */
|
||||
- while (hash_get_n_entries (cached_dirfds) >= max_cached_fds)
|
||||
+ if (max_cached_fds != RLIM_INFINITY)
|
||||
{
|
||||
- struct cached_dirfd *last =
|
||||
- list_entry (lru_list.prev, struct cached_dirfd, lru_link);
|
||||
- if (&last->lru_link == &lru_list)
|
||||
- break;
|
||||
- if (last->fd == keepfd)
|
||||
+ /* Trim off the least recently used entries */
|
||||
+ while (hash_get_n_entries (cached_dirfds) >= max_cached_fds)
|
||||
{
|
||||
- last = list_entry (last->lru_link.prev, struct cached_dirfd, lru_link);
|
||||
+ struct cached_dirfd *last =
|
||||
+ list_entry (lru_list.prev, struct cached_dirfd, lru_link);
|
||||
if (&last->lru_link == &lru_list)
|
||||
break;
|
||||
+ if (last->fd == keepfd)
|
||||
+ {
|
||||
+ last = list_entry (last->lru_link.prev, struct cached_dirfd, lru_link);
|
||||
+ if (&last->lru_link == &lru_list)
|
||||
+ break;
|
||||
+ }
|
||||
+ remove_cached_dirfd (last);
|
||||
}
|
||||
- remove_cached_dirfd (last);
|
||||
}
|
||||
|
||||
/* Only insert if the parent still exists. */
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
36
backport-Fix-failed-assertion-outstate-after_newline.patch
Normal file
36
backport-Fix-failed-assertion-outstate-after_newline.patch
Normal file
@ -0,0 +1,36 @@
|
||||
From 2ab603a64f404d4724a867b8cf9f08ccacbff7c6 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Gruenbacher <agruen@gnu.org>
|
||||
Date: Tue, 16 Jul 2019 01:16:28 +0200
|
||||
Subject: [PATCH 5/8] Fix failed assertion 'outstate->after_newline'
|
||||
|
||||
The assertion triggers when the -o FILE option is used, more than one output
|
||||
file is written into FILE, and one of those files (except the last one) ends in
|
||||
the middle of a line.
|
||||
* src/patch.c (main): Fix the case described above.
|
||||
|
||||
Signed-off-by: Xibo.Wang <wangxb12@chinatelecom.cn>
|
||||
---
|
||||
src/patch.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/src/patch.c b/src/patch.c
|
||||
index 1e1915d..9684794 100644
|
||||
--- a/src/patch.c
|
||||
+++ b/src/patch.c
|
||||
@@ -369,6 +369,13 @@ main (int argc, char **argv)
|
||||
/* outstate.ofp now owns the file descriptor */
|
||||
outfd = -1;
|
||||
}
|
||||
+ else
|
||||
+ {
|
||||
+ /* When writing to a single output file (-o FILE), always pretend
|
||||
+ that the output file ends in a newline. Otherwise, when another
|
||||
+ file is written to the same output file, apply_hunk will fail. */
|
||||
+ outstate.after_newline = true;
|
||||
+ }
|
||||
|
||||
/* find out where all the lines are */
|
||||
if (!skip_rest_of_patch) {
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
34
backport-Fix-test-for-presence-of-BASH_LINENO-0.patch
Normal file
34
backport-Fix-test-for-presence-of-BASH_LINENO-0.patch
Normal file
@ -0,0 +1,34 @@
|
||||
From 1b33a17c9a79de1b6d5acb4da76d3fcedd8dc262 Mon Sep 17 00:00:00 2001
|
||||
From: Kerin Millar <kfm@plushkava.net>
|
||||
Date: Sun, 3 Jan 2021 07:25:00 +0000
|
||||
Subject: [PATCH 7/8] Fix test for presence of BASH_LINENO[0]
|
||||
|
||||
eval is not some sort of magical sandbox for executing code that might cause
|
||||
the shell's parser to take exception. Render the test resilient by carrying
|
||||
it out within a subshell. While at it, position the redirection so that
|
||||
STDERR is, in fact, muted.
|
||||
|
||||
Signed-off-by: Kerin Millar <kfm@plushkava.net>
|
||||
Reported-by: Paolo Pedroni <paolo.pedroni@iol.it>
|
||||
Closes: https://bugs.gentoo.org/738810
|
||||
Signed-off-by: Xibo.Wang <wangxb12@chinatelecom.cn>
|
||||
---
|
||||
tests/test-lib.sh | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
|
||||
index 661da52..b2e787d 100644
|
||||
--- a/tests/test-lib.sh
|
||||
+++ b/tests/test-lib.sh
|
||||
@@ -113,7 +113,7 @@ cleanup() {
|
||||
exit $status
|
||||
}
|
||||
|
||||
-if eval 'test -n "${BASH_LINENO[0]}" 2>/dev/null'; then
|
||||
+if ( eval 'test -n "${BASH_LINENO[0]}"' 2>/dev/null ); then
|
||||
eval '
|
||||
_start_test() {
|
||||
printf "[${BASH_LINENO[2]}] %s -- " "$*"
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
47
backport-Make-the-debug-2-output-more-useful.patch
Normal file
47
backport-Make-the-debug-2-output-more-useful.patch
Normal file
@ -0,0 +1,47 @@
|
||||
From 4be3ee4d25fc777a2508fdd03dc8f701cf4ca91d Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Gruenbacher <agruen@gnu.org>
|
||||
Date: Fri, 17 Aug 2018 10:31:22 +0200
|
||||
Subject: [PATCH] Make the (debug & 2) output more useful
|
||||
|
||||
* src/pch.c (another_hunk): In the (debug & 2) output, fix how empty
|
||||
lines that are not part of the patch context are printed. Also, add
|
||||
newlines to lines that are missing them to keep the output readable.
|
||||
|
||||
Signed-off-by: Xibo.Wang <wangxb12@chinatelecom.cn>
|
||||
---
|
||||
src/pch.c | 12 +++++++++---
|
||||
1 file changed, 9 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/pch.c b/src/pch.c
|
||||
index 4368561..aa0caf4 100644
|
||||
--- a/src/pch.c
|
||||
+++ b/src/pch.c
|
||||
@@ -1923,8 +1923,13 @@ another_hunk (enum diff difftype, bool rev)
|
||||
lin i;
|
||||
|
||||
for (i = 0; i <= p_end + 1; i++) {
|
||||
- fprintf (stderr, "%s %c",
|
||||
- format_linenum (numbuf0, i),
|
||||
+ fputs (format_linenum (numbuf0, i), stderr);
|
||||
+ if (p_Char[i] == '\n')
|
||||
+ {
|
||||
+ fputc('\n', stderr);
|
||||
+ continue;
|
||||
+ }
|
||||
+ fprintf (stderr, " %c",
|
||||
p_Char[i]);
|
||||
if (p_Char[i] == '*')
|
||||
fprintf (stderr, " %s,%s\n",
|
||||
@@ -1937,7 +1942,8 @@ another_hunk (enum diff difftype, bool rev)
|
||||
else if (p_Char[i] != '^')
|
||||
{
|
||||
fputs(" |", stderr);
|
||||
- pch_write_line (i, stderr);
|
||||
+ if (! pch_write_line (i, stderr))
|
||||
+ fputc('\n', stderr);
|
||||
}
|
||||
else
|
||||
fputc('\n', stderr);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
62
backport-Pass-the-correct-stat-to-backup-files.patch
Normal file
62
backport-Pass-the-correct-stat-to-backup-files.patch
Normal file
@ -0,0 +1,62 @@
|
||||
From c835ecc67b7e37c0d0b7dd7e032209fdaa285808 Mon Sep 17 00:00:00 2001
|
||||
From: Takashi Iwai <tiwai@suse.de>
|
||||
Date: Wed, 6 Apr 2022 10:48:35 +0200
|
||||
Subject: [PATCH] Pass the correct stat to backup files
|
||||
|
||||
The last case to call output_file() in the main loop is
|
||||
output_file (outname, NULL, &tmpoutst, NULL, NULL,
|
||||
file_type | 0, backup);
|
||||
and this essentially means to create a backup file (where to=NULL)
|
||||
only if backup=true, and does nothing else.
|
||||
|
||||
And, in the current code, the passed file stat (&tmpoutst) is a file
|
||||
stat of the temporary file that has been processed, not the original
|
||||
file (outname) to be backed up. When the backup is performed
|
||||
immediately, this is no big problem. However, output_file() may
|
||||
schedule the deferred handling, and the given file may be backed up at
|
||||
a later point. The problem is that create_backup() tries to avoid the
|
||||
backup of the same file twice, and it checks the given stat i-node
|
||||
number in the hash list. Since it's a stat of a temporary file, the
|
||||
same i-node number may be reused once a temp file is deleted and
|
||||
another is created. This results in a false-positive detection of the
|
||||
already existing file, eventually missing a backup file.
|
||||
|
||||
This patch attempts to address the issue:
|
||||
- Modify the condition for better understanding, clearly indicating
|
||||
that the code there is for creating a backup file
|
||||
- Pass the stat of the original file instead of a temporary file
|
||||
|
||||
BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1198106
|
||||
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
||||
Signed-off-by: Jean Delvare <jdelvare@suse.de>
|
||||
---
|
||||
src/patch.c | 13 ++++++++++---
|
||||
1 file changed, 10 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/patch.c b/src/patch.c
|
||||
index 9684794..5a61241 100644
|
||||
--- a/src/patch.c
|
||||
+++ b/src/patch.c
|
||||
@@ -622,9 +622,16 @@ main (int argc, char **argv)
|
||||
output_file (NULL, NULL, NULL, inname, &instat,
|
||||
mode, backup);
|
||||
}
|
||||
- else
|
||||
- output_file (outname, NULL, &tmpoutst, NULL, NULL,
|
||||
- file_type | 0, backup);
|
||||
+ else if (backup)
|
||||
+ {
|
||||
+ struct stat outstat;
|
||||
+
|
||||
+ if (stat_file (outname, &outstat, NULL) != 0)
|
||||
+ say ("Cannot stat file %s, skipping backup\n", outname);
|
||||
+ else
|
||||
+ output_file (outname, NULL, &outstat, NULL, NULL,
|
||||
+ file_type | 0, true);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
From 78ee5267f712c38f3343964533fb9fb7c4f70539 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Gruenbacher <agruen@gnu.org>
|
||||
Date: Thu, 27 Jun 2019 11:09:31 +0200
|
||||
Subject: [PATCH 1/8] Skip "ed" test when the ed utility is not installed
|
||||
|
||||
* tests/ed-style: Require ed.
|
||||
|
||||
Signed-off-by: Xibo.Wang <wangxb12@chinatelecom.cn>
|
||||
|
||||
Conflicts:
|
||||
tests/ed-style
|
||||
---
|
||||
tests/ed-style | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/ed-style b/tests/ed-style
|
||||
index ca8e958..9907cb6 100644
|
||||
--- a/tests/ed-style
|
||||
+++ b/tests/ed-style
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
|
||||
-require_cat
|
||||
+require cat
|
||||
+require ed
|
||||
use_local_patch
|
||||
use_tmpdir
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
85
backport-maint-avoid-warnings-from-GCC8.patch
Normal file
85
backport-maint-avoid-warnings-from-GCC8.patch
Normal file
@ -0,0 +1,85 @@
|
||||
From 040f114197ca1797bf84caedb252119c1ec07be5 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Meyering <jim@meyering.net>
|
||||
Date: Fri, 6 Apr 2018 17:17:11 -0700
|
||||
Subject: [PATCH] maint: avoid warnings from GCC8
|
||||
|
||||
Hi Andreas,
|
||||
|
||||
I configured with --enable-gcc-warnings and bleeding-edge gcc
|
||||
(version 8.0.1 20180406) and hit some warning-escalated-to-errors.
|
||||
This fixes them:
|
||||
|
||||
>From a71ddb200dbe7ac0f9258796b5a51979b2740e88 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Meyering <meyering@fb.com>
|
||||
Date: Fri, 6 Apr 2018 16:47:00 -0700
|
||||
Subject: [PATCH] maint: avoid warnings from GCC8
|
||||
|
||||
* src/common.h (FALLTHROUGH): Define.
|
||||
* src/patch.c (abort_hunk_context): Use FALLTHROUGH macro in place of
|
||||
a comment. This avoids a warning from -Wimplicit-fallthrough=.
|
||||
* src/pch.c (do_ed_script): Add otherwise unnecessary initialization
|
||||
to avoid warning from -Wmaybe-uninitialized.
|
||||
(another_hunk): Use FALLTHROUGH macro here, too, twice.
|
||||
|
||||
Conflicts:
|
||||
src/pch.c
|
||||
---
|
||||
src/common.h | 8 ++++++++
|
||||
src/patch.c | 2 +-
|
||||
src/pch.c | 4 ++--
|
||||
3 files changed, 11 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/common.h b/src/common.h
|
||||
index 2524628..dfac17a 100644
|
||||
--- a/src/common.h
|
||||
+++ b/src/common.h
|
||||
@@ -223,3 +223,11 @@ bool merge_hunk (int hunk, struct outstate *, lin where, bool *);
|
||||
#else
|
||||
# define merge_hunk(hunk, outstate, where, somefailed) false
|
||||
#endif
|
||||
+
|
||||
+#ifndef FALLTHROUGH
|
||||
+# if __GNUC__ < 7
|
||||
+# define FALLTHROUGH ((void) 0)
|
||||
+# else
|
||||
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
|
||||
+# endif
|
||||
+#endif
|
||||
diff --git a/src/patch.c b/src/patch.c
|
||||
index 065a05a..99a5904 100644
|
||||
--- a/src/patch.c
|
||||
+++ b/src/patch.c
|
||||
@@ -1382,7 +1382,7 @@ abort_hunk_context (bool header, bool reverse)
|
||||
break;
|
||||
case ' ': case '-': case '+': case '!':
|
||||
fprintf (rejfp, "%c ", pch_char (i));
|
||||
- /* fall into */
|
||||
+ FALLTHROUGH;
|
||||
case '\n':
|
||||
pch_write_line (i, rejfp);
|
||||
break;
|
||||
diff --git a/src/pch.c b/src/pch.c
|
||||
index 8dda771..4368561 100644
|
||||
--- a/src/pch.c
|
||||
+++ b/src/pch.c
|
||||
@@ -1742,7 +1742,7 @@ another_hunk (enum diff difftype, bool rev)
|
||||
break;
|
||||
case '=':
|
||||
ch = ' ';
|
||||
- /* FALL THROUGH */
|
||||
+ FALLTHROUGH;
|
||||
case ' ':
|
||||
if (fillsrc > p_ptrn_lines) {
|
||||
free(s);
|
||||
@@ -1763,7 +1763,7 @@ another_hunk (enum diff difftype, bool rev)
|
||||
p_end = fillsrc-1;
|
||||
return -1;
|
||||
}
|
||||
- /* FALL THROUGH */
|
||||
+ FALLTHROUGH;
|
||||
case '+':
|
||||
if (filldst > p_end) {
|
||||
free(s);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
38
patch.spec
38
patch.spec
@ -1,6 +1,6 @@
|
||||
Name: patch
|
||||
Version: 2.7.6
|
||||
Release: 16
|
||||
Release: 22
|
||||
Summary: Utiliity which applies a patch file to original files.
|
||||
License: GPLv3+
|
||||
URL: http://www.gnu.org/software/patch/patch.html
|
||||
@ -17,6 +17,18 @@ Patch8: patch-selinux.patch
|
||||
Patch9: Avoid-set_file_attributes-sign-conversion-warnings.patch
|
||||
Patch10: Test-suite-compatibility-fixes.patch
|
||||
Patch11: Test-suite-fix-Korn-shell-incompatibility.patch
|
||||
Patch12: backport-maint-avoid-warnings-from-GCC8.patch
|
||||
Patch13: backport-Make-the-debug-2-output-more-useful.patch
|
||||
Patch14: backport--Improve-support-for-memory-leak-detection.patch
|
||||
Patch15: backport-Skip-ed-test-when-the-ed-utility-is-not-installed.patch
|
||||
Patch16: backport-Abort-when-cleaning-up-fails.patch
|
||||
Patch17: backport-Don-t-crash-when-RLIMIT_NOFILE-is-set-to-RLIM_INFINI.patch
|
||||
Patch18: backport-Avoid-invalid-memory-access-in-context-format-diffs.patch
|
||||
Patch19: backport-Fix-failed-assertion-outstate-after_newline.patch
|
||||
Patch20: backport-Add-missing-section-tests-to-context-format-test-cas.patch
|
||||
Patch21: backport-Fix-test-for-presence-of-BASH_LINENO-0.patch
|
||||
Patch22: backport-Pass-the-correct-stat-to-backup-files.patch
|
||||
Patch23: backport-CVE-2018-17942.patch
|
||||
|
||||
BuildRequires: gcc libselinux-devel libattr-devel ed
|
||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-root
|
||||
@ -59,6 +71,30 @@ CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE"
|
||||
%{_mandir}/man1/*
|
||||
|
||||
%changelog
|
||||
* Mon Feb 10 2025 fuanan <fuanan3@h-partners.com> - 2.7.6-22
|
||||
- fix CVE-2018-17942
|
||||
|
||||
* Mon Apr 29 2024 kouwenqi <kouwenqi@kylinos.cn> - 2.7.6-21
|
||||
- Pass the correct stat to backup files
|
||||
|
||||
* Fri Dec 30 2022 Xibo.Wang <wangxb12@chinatelecom.cn> - 2.7.6-20
|
||||
- Skip "ed" test when the ed utility is not installed
|
||||
- Abort when cleaning up fails
|
||||
- Don't crash when RLIMIT_NOFILE is set to RLIM_INFINITY
|
||||
- Avoid invalid memory access in context format diffs
|
||||
- Fix failed assertion 'outstate->after_newline'
|
||||
- Add missing-section tests to context-format test case
|
||||
- Fix test for presence of BASH_LINENO[0]
|
||||
|
||||
* Wed Dec 28 2022 Xibo.Wang <wangxb12@chinatelecom.cn> - 2.7.6-19
|
||||
- Improve support for memory leak detection
|
||||
|
||||
* Wed Dec 28 2022 Xibo.Wang <wangxb12@chinatelecom.cn> - 2.7.6-18
|
||||
- Make the (debug & 2) output more useful
|
||||
|
||||
* Wed Dec 28 2022 Xibo.Wang <wangxb12@chinatelecom.cn> - 2.7.6-17
|
||||
- maint: avoid warnings from GCC8
|
||||
|
||||
* Wed Dec 28 2022 Xibo.Wang <wangxb12@chinatelecom.cn> - 2.7.6-16
|
||||
- Test suite: fix Korn shell incompatibility
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user