From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 56658138334 for ; Sun, 26 Aug 2018 14:32:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 02811E089B; Sun, 26 Aug 2018 14:32:41 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B8B70E089B for ; Sun, 26 Aug 2018 14:32:40 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9FA4D335CA0 for ; Sun, 26 Aug 2018 14:32:38 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B899139D for ; Sun, 26 Aug 2018 14:32:36 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1535293938.dedeef3e8b0b5cb7010149efa4e92892fa74ed36.whissi@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/patch/files/, sys-devel/patch/ X-VCS-Repository: repo/gentoo X-VCS-Files: sys-devel/patch/files/patch-2.7.6-fix-error-handling-with-git-style-patches.patch sys-devel/patch/patch-2.7.6-r2.ebuild X-VCS-Directories: sys-devel/patch/ sys-devel/patch/files/ X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: dedeef3e8b0b5cb7010149efa4e92892fa74ed36 X-VCS-Branch: master Date: Sun, 26 Aug 2018 14:32:36 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 04b9c523-f696-4a6b-8b1f-340cd3f3f81f X-Archives-Hash: 21e41561db275ef477f96ca4930d4ad2 commit: dedeef3e8b0b5cb7010149efa4e92892fa74ed36 Author: Thomas Deutschmann gentoo org> AuthorDate: Sun Aug 26 14:32:18 2018 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Sun Aug 26 14:32:18 2018 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dedeef3e sys-devel/patch: fix error handling with git-style patches Closes: https://bugs.gentoo.org/664640 Package-Manager: Portage-2.3.48, Repoman-2.3.10 ...fix-error-handling-with-git-style-patches.patch | 125 +++++++++++++++++++++ sys-devel/patch/patch-2.7.6-r2.ebuild | 36 ++++++ 2 files changed, 161 insertions(+) diff --git a/sys-devel/patch/files/patch-2.7.6-fix-error-handling-with-git-style-patches.patch b/sys-devel/patch/files/patch-2.7.6-fix-error-handling-with-git-style-patches.patch new file mode 100644 index 00000000000..a4f127dd7ce --- /dev/null +++ b/sys-devel/patch/files/patch-2.7.6-fix-error-handling-with-git-style-patches.patch @@ -0,0 +1,125 @@ +Backport for Gentoo patch-2.7.x. + +https://bugs.gentoo.org/664640 + + +Original patch: +Author: Lubomir Rintel +Date: Tue Feb 27 16:52:00 2018 +0100 +Subject: Fix error handling with git-style patches + +When an error is encountered in output_files(), the subsequent call to +cleanup() calls back into output_files() resulting in an infinte recursion. +This is trivially reproduced with a git-style patch (which utilizes +output_file_later()) that tries to patch a nonexistent or unreadable +file (see attached test case). + +* src/patch.c: (output_files) clear the files_to_output list before +iterating it, so that recursive calls won't iterate the same files. +* tests/git-error: New test case. +* tests/Makefile.am (TESTS): Add test case. + +Origin: https://lists.gnu.org/archive/html/bug-patch/2018-02/msg00010.html + +--- a/src/patch.c ++++ b/src/patch.c +@@ -1938,8 +1938,12 @@ output_files (struct stat const *st) + { + gl_list_iterator_t iter; + const void *elt; ++ gl_list_t files; + +- iter = gl_list_iterator (files_to_output); ++ files = files_to_output; ++ init_files_to_output (); ++ ++ iter = gl_list_iterator (files); + while (gl_list_iterator_next (&iter, &elt, NULL)) + { + const struct file_to_output *file_to_output = elt; +@@ -1957,8 +1961,8 @@ output_files (struct stat const *st) + /* Free the list up to here. */ + for (;;) + { +- const void *elt2 = gl_list_get_at (files_to_output, 0); +- gl_list_remove_at (files_to_output, 0); ++ const void *elt2 = gl_list_get_at (files, 0); ++ gl_list_remove_at (files, 0); + if (elt == elt2) + break; + } +@@ -1967,7 +1971,7 @@ output_files (struct stat const *st) + } + } + gl_list_iterator_free (&iter); +- gl_list_clear (files_to_output); ++ gl_list_free (files); + } + + /* Fatal exit with cleanup. */ +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -40,6 +40,7 @@ TESTS = \ + filename-choice \ + git-binary-diff \ + git-cleanup \ ++ git-error \ + garbage \ + global-reject-files \ + inname \ +--- a/tests/Makefile.in ++++ b/tests/Makefile.in +@@ -1316,6 +1316,7 @@ TESTS = \ + filename-choice \ + git-binary-diff \ + git-cleanup \ ++ git-error \ + garbage \ + global-reject-files \ + inname \ +@@ -1695,6 +1696,13 @@ git-cleanup.log: git-cleanup + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) ++git-error.log: git-error ++ @p='git-error'; \ ++ b='git-error'; \ ++ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ ++ --log-file $$b.log --trs-file $$b.trs \ ++ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ ++ "$$tst" $(AM_TESTS_FD_REDIRECT) + garbage.log: garbage + @p='garbage'; \ + b='garbage'; \ +--- /dev/null ++++ b/tests/git-error +@@ -0,0 +1,29 @@ ++# Copyright (C) 2018 Free Software Foundation, Inc. ++# ++# Copying and distribution of this file, with or without modification, ++# in any medium, are permitted without royalty provided the copyright ++# notice and this notice are preserved. ++ ++. $srcdir/test-lib.sh ++ ++require cat ++use_local_patch ++use_tmpdir ++ ++cat > f.diff <