blob: 2a09d0c03b54da6daee73be21312f68c7c3f4316 [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001From b5a91a01e5d0897facdd0f49d64b76b0f02b43e1 Mon Sep 17 00:00:00 2001
2From: Andreas Gruenbacher <agruen@gnu.org>
3Date: Fri, 6 Apr 2018 11:34:51 +0200
4Subject: [PATCH] Allow input files to be missing for ed-style patches
5
6* src/pch.c (do_ed_script): Allow input files to be missing so that new
7files will be created as with non-ed-style patches.
8
9Upstream-Status: Backport [http://git.savannah.gnu.org/cgit/patch.git/commit/?id=b5a91a01e5d0897facdd0f49d64b76b0f02b43e1]
10CVE: CVE-2018-1000156
11
12Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
13---
14 src/pch.c | 8 +++++---
15 1 file changed, 5 insertions(+), 3 deletions(-)
16
17diff --git a/src/pch.c b/src/pch.c
18index bc6278c..0c5cc26 100644
19--- a/src/pch.c
20+++ b/src/pch.c
21@@ -2394,9 +2394,11 @@ do_ed_script (char const *inname, char const *outname,
22
23 if (! dry_run && ! skip_rest_of_patch) {
24 int exclusive = *outname_needs_removal ? 0 : O_EXCL;
25- assert (! inerrno);
26- *outname_needs_removal = true;
27- copy_file (inname, outname, 0, exclusive, instat.st_mode, true);
28+ if (inerrno != ENOENT)
29+ {
30+ *outname_needs_removal = true;
31+ copy_file (inname, outname, 0, exclusive, instat.st_mode, true);
32+ }
33 sprintf (buf, "%s %s%s", editor_program,
34 verbosity == VERBOSE ? "" : "- ",
35 outname);
36--
372.7.4
38