forked from pool/patch
0c9f15e1a7
lines in pch_swap. This bug was causing a double free leading to a crash (boo#1080985 CVE-2018-6952). - abort-when-cleaning-up-fails.patch: Abort when cleaning up fails. This bug could cause an infinite loop when a patch wouldn't apply, leading to a segmentation fault (boo#1111572). - dont-follow-symlinks-unless-asked.patch: Don't follow symlinks unless --follow-symlinks is given. This increases the security against malicious patches (boo#1142041 CVE-2019-13636). - pass-the-correct-stat-to-backup-files.patch: Pass the correct stat to backup files. This bug would occasionally cause backup files to be missing when all hunks failed to apply (boo#1198106). OBS-URL: https://build.opensuse.org/package/show/devel:tools/patch?expand=0&rev=64
49 lines
1.4 KiB
Diff
49 lines
1.4 KiB
Diff
From: Andreas Gruenbacher <agruen@gnu.org>
|
|
Date: Fri, 28 Jun 2019 00:30:25 +0200
|
|
Subject: Abort when cleaning up fails
|
|
Patch-mainline: Yes
|
|
Git-commit: b7b028a77bd855f6f56b17c8837fc1cca77b469d
|
|
References: boo#1111572 savannah#54845
|
|
|
|
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.
|
|
---
|
|
src/patch.c | 8 ++++++--
|
|
1 file changed, 6 insertions(+), 2 deletions(-)
|
|
|
|
--- a/src/patch.c
|
|
+++ b/src/patch.c
|
|
@@ -681,7 +681,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)
|
|
@@ -1977,7 +1976,6 @@ void
|
|
fatal_exit (int sig)
|
|
{
|
|
cleanup ();
|
|
-
|
|
if (sig)
|
|
exit_with_signal (sig);
|
|
|
|
@@ -1997,6 +1995,12 @@ remove_if_needed (char const *name, bool
|
|
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);
|