Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame^] | 1 | From b5a91a01e5d0897facdd0f49d64b76b0f02b43e1 Mon Sep 17 00:00:00 2001 |
| 2 | From: Andreas Gruenbacher <agruen@gnu.org> |
| 3 | Date: Fri, 6 Apr 2018 11:34:51 +0200 |
| 4 | Subject: [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 |
| 7 | files will be created as with non-ed-style patches. |
| 8 | |
| 9 | Upstream-Status: Backport [http://git.savannah.gnu.org/cgit/patch.git/commit/?id=b5a91a01e5d0897facdd0f49d64b76b0f02b43e1] |
| 10 | CVE: CVE-2018-1000156 |
| 11 | |
| 12 | Signed-off-by: Jackie Huang <jackie.huang@windriver.com> |
| 13 | --- |
| 14 | src/pch.c | 8 +++++--- |
| 15 | 1 file changed, 5 insertions(+), 3 deletions(-) |
| 16 | |
| 17 | diff --git a/src/pch.c b/src/pch.c |
| 18 | index 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 | -- |
| 37 | 2.7.4 |
| 38 | |