[arch-commits] Commit in patch/repos (3 files)
Date: Wednesday, November 13, 2019 @ 17:48:33 Author: foutrelis Revision: 368409 archrelease: copy trunk to staging-x86_64 Added: patch/repos/staging-x86_64/ patch/repos/staging-x86_64/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch (from rev 368408, patch/trunk/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch) patch/repos/staging-x86_64/PKGBUILD (from rev 368408, patch/trunk/PKGBUILD) + 19599883ffb6a450d2884f081f8ecf68edbed7ee.patch | 99 +++ PKGBUILD | 67 +++ 2 files changed, 166 insertions(+) Copied: patch/repos/staging-x86_64/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch (from rev 368408, patch/trunk/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch) === --- staging-x86_64/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch (rev 0) +++ staging-x86_64/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch 2019-11-13 17:48:33 UTC (rev 368409) @@ -0,0 +1,99 @@ +From 19599883ffb6a450d2884f081f8ecf68edbed7ee Mon Sep 17 00:00:00 2001 +From: Jean Delvare +Date: Thu, 3 May 2018 14:31:55 +0200 +Subject: [PATCH] Don't leak temporary file on failed ed-style patch + +Now that we write ed-style patches to a temporary file before we +apply them, we need to ensure that the temporary file is removed +before we leave, even on fatal error. + +* src/pch.c (do_ed_script): Use global TMPEDNAME instead of local + tmpname. Don't unlink the file directly, instead tag it for removal + at exit time. +* src/patch.c (cleanup): Unlink TMPEDNAME at exit. + +This closes bug #53820: +https://savannah.gnu.org/bugs/index.php?53820 + +Fixes: 123eaff0d5d1 ("Fix arbitrary command execution in ed-style patches (CVE-2018-1000156)") +--- + src/common.h | 2 ++ + src/patch.c | 1 + + src/pch.c| 11 +-- + 3 files changed, 8 insertions(+), 6 deletions(-) + +diff --git a/src/common.h b/src/common.h +index 904a3f8..53c5e32 100644 +--- a/src/common.h b/src/common.h +@@ -94,10 +94,12 @@ XTERN char const *origsuff; + XTERN char const * TMPINNAME; + XTERN char const * TMPOUTNAME; + XTERN char const * TMPPATNAME; ++XTERN char const * TMPEDNAME; + + XTERN bool TMPINNAME_needs_removal; + XTERN bool TMPOUTNAME_needs_removal; + XTERN bool TMPPATNAME_needs_removal; ++XTERN bool TMPEDNAME_needs_removal; + + #ifdef DEBUGGING + XTERN int debug; +diff --git a/src/patch.c b/src/patch.c +index 3fcaec5..9146597 100644 +--- a/src/patch.c b/src/patch.c +@@ -1999,6 +1999,7 @@ cleanup (void) + remove_if_needed (TMPINNAME, &TMPINNAME_needs_removal); + remove_if_needed (TMPOUTNAME, &TMPOUTNAME_needs_removal); + remove_if_needed (TMPPATNAME, &TMPPATNAME_needs_removal); ++ remove_if_needed (TMPEDNAME, &TMPEDNAME_needs_removal); + remove_if_needed (TMPREJNAME, &TMPREJNAME_needs_removal); + output_files (NULL); + } +diff --git a/src/pch.c b/src/pch.c +index 79a3c99..1bb3153 100644 +--- a/src/pch.c b/src/pch.c +@@ -2396,7 +2396,6 @@ do_ed_script (char const *inname, char const *outname, + file_offset beginning_of_this_line; + size_t chars_read; + FILE *tmpfp = 0; +-char const *tmpname; + int tmpfd; + pid_t pid; + +@@ -2411,12 +2410,13 @@ do_ed_script (char const *inname, char const *outname, + invalid commands and treats the next line as a new command, which + can lead to arbitrary command execution. */ + +- tmpfd = make_tempfile (&tmpname, 'e', NULL, O_RDWR | O_BINARY, 0); ++ tmpfd = make_tempfile (&TMPEDNAME, 'e', NULL, O_RDWR | O_BINARY, 0); + if (tmpfd == -1) +-pfatal ("Can't create temporary file %s", quotearg (tmpname)); ++pfatal ("Can't create temporary file %s", quotearg (TMPEDNAME)); ++ TMPEDNAME_needs_removal = true; + tmpfp = fdopen (tmpfd, "w+b"); + if (! tmpfp) +-pfatal ("Can't open stream for file %s", quotearg (tmpname)); ++pfatal ("Can't open stream for file %s", quotearg (TMPEDNAME)); + } + + for (;;) { +@@ -2457,7 +2457,7 @@ do_ed_script (char const *inname, char const *outname, + write_fatal (); + + if (lseek (tmpfd, 0, SEEK_SET) == -1) +- pfatal ("Can't rewind to the beginning of file %s", quotearg (tmpname)); ++ pfatal ("Can't rewind to the beginning of file %s", quotearg (TMPEDNAME)); + + if (inerrno != ENOENT) + { +@@ -2484,7 +2484,6 @@ do_ed_script (char const *inname, char const *outname, + pfatal ("Failed to duplicate standard input"); + + fclose (tmpfp); +-safe_unlink (tmpname); + + if (ofp) + { Copied: patch/repos/staging-x86_64/PKGBUILD (from rev 368408, patch/trunk/PKGBUILD) === --- staging-x86_64/PKGBUILD (rev 0) +++ staging-x86_64/PKGBUILD 2019-11-13 17:48:33 UTC (rev 368409) @@ -0,0 +1,67 @@ +# M
[arch-commits] Commit in patch/repos (3 files)
Date: Wednesday, November 13, 2019 @ 00:08:54 Author: allan Revision: 368034 archrelease: copy trunk to testing-x86_64 Added: patch/repos/testing-x86_64/ patch/repos/testing-x86_64/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch (from rev 368033, patch/trunk/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch) patch/repos/testing-x86_64/PKGBUILD (from rev 368033, patch/trunk/PKGBUILD) + 19599883ffb6a450d2884f081f8ecf68edbed7ee.patch | 99 +++ PKGBUILD | 67 +++ 2 files changed, 166 insertions(+) Copied: patch/repos/testing-x86_64/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch (from rev 368033, patch/trunk/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch) === --- testing-x86_64/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch (rev 0) +++ testing-x86_64/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch 2019-11-13 00:08:54 UTC (rev 368034) @@ -0,0 +1,99 @@ +From 19599883ffb6a450d2884f081f8ecf68edbed7ee Mon Sep 17 00:00:00 2001 +From: Jean Delvare +Date: Thu, 3 May 2018 14:31:55 +0200 +Subject: [PATCH] Don't leak temporary file on failed ed-style patch + +Now that we write ed-style patches to a temporary file before we +apply them, we need to ensure that the temporary file is removed +before we leave, even on fatal error. + +* src/pch.c (do_ed_script): Use global TMPEDNAME instead of local + tmpname. Don't unlink the file directly, instead tag it for removal + at exit time. +* src/patch.c (cleanup): Unlink TMPEDNAME at exit. + +This closes bug #53820: +https://savannah.gnu.org/bugs/index.php?53820 + +Fixes: 123eaff0d5d1 ("Fix arbitrary command execution in ed-style patches (CVE-2018-1000156)") +--- + src/common.h | 2 ++ + src/patch.c | 1 + + src/pch.c| 11 +-- + 3 files changed, 8 insertions(+), 6 deletions(-) + +diff --git a/src/common.h b/src/common.h +index 904a3f8..53c5e32 100644 +--- a/src/common.h b/src/common.h +@@ -94,10 +94,12 @@ XTERN char const *origsuff; + XTERN char const * TMPINNAME; + XTERN char const * TMPOUTNAME; + XTERN char const * TMPPATNAME; ++XTERN char const * TMPEDNAME; + + XTERN bool TMPINNAME_needs_removal; + XTERN bool TMPOUTNAME_needs_removal; + XTERN bool TMPPATNAME_needs_removal; ++XTERN bool TMPEDNAME_needs_removal; + + #ifdef DEBUGGING + XTERN int debug; +diff --git a/src/patch.c b/src/patch.c +index 3fcaec5..9146597 100644 +--- a/src/patch.c b/src/patch.c +@@ -1999,6 +1999,7 @@ cleanup (void) + remove_if_needed (TMPINNAME, &TMPINNAME_needs_removal); + remove_if_needed (TMPOUTNAME, &TMPOUTNAME_needs_removal); + remove_if_needed (TMPPATNAME, &TMPPATNAME_needs_removal); ++ remove_if_needed (TMPEDNAME, &TMPEDNAME_needs_removal); + remove_if_needed (TMPREJNAME, &TMPREJNAME_needs_removal); + output_files (NULL); + } +diff --git a/src/pch.c b/src/pch.c +index 79a3c99..1bb3153 100644 +--- a/src/pch.c b/src/pch.c +@@ -2396,7 +2396,6 @@ do_ed_script (char const *inname, char const *outname, + file_offset beginning_of_this_line; + size_t chars_read; + FILE *tmpfp = 0; +-char const *tmpname; + int tmpfd; + pid_t pid; + +@@ -2411,12 +2410,13 @@ do_ed_script (char const *inname, char const *outname, + invalid commands and treats the next line as a new command, which + can lead to arbitrary command execution. */ + +- tmpfd = make_tempfile (&tmpname, 'e', NULL, O_RDWR | O_BINARY, 0); ++ tmpfd = make_tempfile (&TMPEDNAME, 'e', NULL, O_RDWR | O_BINARY, 0); + if (tmpfd == -1) +-pfatal ("Can't create temporary file %s", quotearg (tmpname)); ++pfatal ("Can't create temporary file %s", quotearg (TMPEDNAME)); ++ TMPEDNAME_needs_removal = true; + tmpfp = fdopen (tmpfd, "w+b"); + if (! tmpfp) +-pfatal ("Can't open stream for file %s", quotearg (tmpname)); ++pfatal ("Can't open stream for file %s", quotearg (TMPEDNAME)); + } + + for (;;) { +@@ -2457,7 +2457,7 @@ do_ed_script (char const *inname, char const *outname, + write_fatal (); + + if (lseek (tmpfd, 0, SEEK_SET) == -1) +- pfatal ("Can't rewind to the beginning of file %s", quotearg (tmpname)); ++ pfatal ("Can't rewind to the beginning of file %s", quotearg (TMPEDNAME)); + + if (inerrno != ENOENT) + { +@@ -2484,7 +2484,6 @@ do_ed_script (char const *inname, char const *outname, + pfatal ("Failed to duplicate standard input"); + + fclose (tmpfp); +-safe_unlink (tmpname); + + if (ofp) + { Copied: patch/repos/testing-x86_64/PKGBUILD (from rev 368033, patch/trunk/PKGBUILD) === --- testing-x86_64/PKGBUILD (rev 0) +++ testing-x86_64/PKGBUILD 2019-11-13 00:08:54 UTC (rev 368034) @@ -0,0 +1,67 @@ +# Maint
[arch-commits] Commit in patch/repos (3 files)
Date: Tuesday, November 13, 2018 @ 23:43:26 Author: anthraxx Revision: 339662 archrelease: copy trunk to testing-x86_64 Added: patch/repos/testing-x86_64/ patch/repos/testing-x86_64/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch (from rev 339661, patch/trunk/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch) patch/repos/testing-x86_64/PKGBUILD (from rev 339661, patch/trunk/PKGBUILD) + 19599883ffb6a450d2884f081f8ecf68edbed7ee.patch | 99 +++ PKGBUILD | 67 +++ 2 files changed, 166 insertions(+) Copied: patch/repos/testing-x86_64/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch (from rev 339661, patch/trunk/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch) === --- testing-x86_64/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch (rev 0) +++ testing-x86_64/19599883ffb6a450d2884f081f8ecf68edbed7ee.patch 2018-11-13 23:43:26 UTC (rev 339662) @@ -0,0 +1,99 @@ +From 19599883ffb6a450d2884f081f8ecf68edbed7ee Mon Sep 17 00:00:00 2001 +From: Jean Delvare +Date: Thu, 3 May 2018 14:31:55 +0200 +Subject: [PATCH] Don't leak temporary file on failed ed-style patch + +Now that we write ed-style patches to a temporary file before we +apply them, we need to ensure that the temporary file is removed +before we leave, even on fatal error. + +* src/pch.c (do_ed_script): Use global TMPEDNAME instead of local + tmpname. Don't unlink the file directly, instead tag it for removal + at exit time. +* src/patch.c (cleanup): Unlink TMPEDNAME at exit. + +This closes bug #53820: +https://savannah.gnu.org/bugs/index.php?53820 + +Fixes: 123eaff0d5d1 ("Fix arbitrary command execution in ed-style patches (CVE-2018-1000156)") +--- + src/common.h | 2 ++ + src/patch.c | 1 + + src/pch.c| 11 +-- + 3 files changed, 8 insertions(+), 6 deletions(-) + +diff --git a/src/common.h b/src/common.h +index 904a3f8..53c5e32 100644 +--- a/src/common.h b/src/common.h +@@ -94,10 +94,12 @@ XTERN char const *origsuff; + XTERN char const * TMPINNAME; + XTERN char const * TMPOUTNAME; + XTERN char const * TMPPATNAME; ++XTERN char const * TMPEDNAME; + + XTERN bool TMPINNAME_needs_removal; + XTERN bool TMPOUTNAME_needs_removal; + XTERN bool TMPPATNAME_needs_removal; ++XTERN bool TMPEDNAME_needs_removal; + + #ifdef DEBUGGING + XTERN int debug; +diff --git a/src/patch.c b/src/patch.c +index 3fcaec5..9146597 100644 +--- a/src/patch.c b/src/patch.c +@@ -1999,6 +1999,7 @@ cleanup (void) + remove_if_needed (TMPINNAME, &TMPINNAME_needs_removal); + remove_if_needed (TMPOUTNAME, &TMPOUTNAME_needs_removal); + remove_if_needed (TMPPATNAME, &TMPPATNAME_needs_removal); ++ remove_if_needed (TMPEDNAME, &TMPEDNAME_needs_removal); + remove_if_needed (TMPREJNAME, &TMPREJNAME_needs_removal); + output_files (NULL); + } +diff --git a/src/pch.c b/src/pch.c +index 79a3c99..1bb3153 100644 +--- a/src/pch.c b/src/pch.c +@@ -2396,7 +2396,6 @@ do_ed_script (char const *inname, char const *outname, + file_offset beginning_of_this_line; + size_t chars_read; + FILE *tmpfp = 0; +-char const *tmpname; + int tmpfd; + pid_t pid; + +@@ -2411,12 +2410,13 @@ do_ed_script (char const *inname, char const *outname, + invalid commands and treats the next line as a new command, which + can lead to arbitrary command execution. */ + +- tmpfd = make_tempfile (&tmpname, 'e', NULL, O_RDWR | O_BINARY, 0); ++ tmpfd = make_tempfile (&TMPEDNAME, 'e', NULL, O_RDWR | O_BINARY, 0); + if (tmpfd == -1) +-pfatal ("Can't create temporary file %s", quotearg (tmpname)); ++pfatal ("Can't create temporary file %s", quotearg (TMPEDNAME)); ++ TMPEDNAME_needs_removal = true; + tmpfp = fdopen (tmpfd, "w+b"); + if (! tmpfp) +-pfatal ("Can't open stream for file %s", quotearg (tmpname)); ++pfatal ("Can't open stream for file %s", quotearg (TMPEDNAME)); + } + + for (;;) { +@@ -2457,7 +2457,7 @@ do_ed_script (char const *inname, char const *outname, + write_fatal (); + + if (lseek (tmpfd, 0, SEEK_SET) == -1) +- pfatal ("Can't rewind to the beginning of file %s", quotearg (tmpname)); ++ pfatal ("Can't rewind to the beginning of file %s", quotearg (TMPEDNAME)); + + if (inerrno != ENOENT) + { +@@ -2484,7 +2484,6 @@ do_ed_script (char const *inname, char const *outname, + pfatal ("Failed to duplicate standard input"); + + fclose (tmpfp); +-safe_unlink (tmpname); + + if (ofp) + { Copied: patch/repos/testing-x86_64/PKGBUILD (from rev 339661, patch/trunk/PKGBUILD) === --- testing-x86_64/PKGBUILD (rev 0) +++ testing-x86_64/PKGBUILD 2018-11-13 23:43:26 UTC (rev 339662) @@ -0,0 +1,67 @@ +# Main
[arch-commits] Commit in patch/repos (3 files)
Date: Tuesday, September 25, 2018 @ 20:23:46 Author: jelle Revision: 335382 archrelease: copy trunk to testing-x86_64 Added: patch/repos/testing-x86_64/ patch/repos/testing-x86_64/CVE-2018-1000156.patch (from rev 335381, patch/trunk/CVE-2018-1000156.patch) patch/repos/testing-x86_64/PKGBUILD (from rev 335381, patch/trunk/PKGBUILD) + CVE-2018-1000156.patch | 142 +++ PKGBUILD | 61 2 files changed, 203 insertions(+) Copied: patch/repos/testing-x86_64/CVE-2018-1000156.patch (from rev 335381, patch/trunk/CVE-2018-1000156.patch) === --- testing-x86_64/CVE-2018-1000156.patch (rev 0) +++ testing-x86_64/CVE-2018-1000156.patch 2018-09-25 20:23:46 UTC (rev 335382) @@ -0,0 +1,142 @@ +diff -aur patch-2.7.6.old/src/pch.c patch-2.7.6/src/pch.c +--- patch-2.7.6.old/src/pch.c 2018-09-25 21:35:15.468805478 +0200 patch-2.7.6/src/pch.c 2018-09-25 21:39:33.691394951 +0200 +@@ -33,6 +33,7 @@ + # include + #endif + #include ++#include + + #define INITHUNKMAX 125 /* initial dynamic allocation size */ + +@@ -2388,22 +2389,28 @@ + static char const editor_program[] = EDITOR_PROGRAM; + + file_offset beginning_of_this_line; +-FILE *pipefp = 0; + size_t chars_read; ++FILE *tmpfp = 0; ++char const *tmpname; ++int tmpfd; ++pid_t pid; ++ ++if (! dry_run && ! skip_rest_of_patch) ++ { ++ /* Write ed script to a temporary file. This causes ed to abort on ++ invalid commands such as when line numbers or ranges exceed the ++ number of available lines. When ed reads from a pipe, it rejects ++ invalid commands and treats the next line as a new command, which ++ can lead to arbitrary command execution. */ ++ ++ tmpfd = make_tempfile (&tmpname, 'e', NULL, O_RDWR | O_BINARY, 0); ++ if (tmpfd == -1) ++pfatal ("Can't create temporary file %s", quotearg (tmpname)); ++ tmpfp = fdopen (tmpfd, "w+b"); ++ if (! tmpfp) ++pfatal ("Can't open stream for file %s", quotearg (tmpname)); ++ } + +-if (! dry_run && ! skip_rest_of_patch) { +- int exclusive = *outname_needs_removal ? 0 : O_EXCL; +- assert (! inerrno); +- *outname_needs_removal = true; +- copy_file (inname, outname, 0, exclusive, instat.st_mode, true); +- sprintf (buf, "%s %s%s", editor_program, +- verbosity == VERBOSE ? "" : "- ", +- outname); +- fflush (stdout); +- pipefp = popen(buf, binary_transput ? "wb" : "w"); +- if (!pipefp) +-pfatal ("Can't open pipe to %s", quotearg (buf)); +-} + for (;;) { + char ed_command_letter; + beginning_of_this_line = file_tell (pfp); +@@ -2414,14 +2421,14 @@ + } + ed_command_letter = get_ed_command_letter (buf); + if (ed_command_letter) { +- if (pipefp) +- if (! fwrite (buf, sizeof *buf, chars_read, pipefp)) ++ if (tmpfp) ++ if (! fwrite (buf, sizeof *buf, chars_read, tmpfp)) + write_fatal (); + if (ed_command_letter != 'd' && ed_command_letter != 's') { + p_pass_comments_through = true; + while ((chars_read = get_line ()) != 0) { +- if (pipefp) +- if (! fwrite (buf, sizeof *buf, chars_read, pipefp)) ++ if (tmpfp) ++ if (! fwrite (buf, sizeof *buf, chars_read, tmpfp)) + write_fatal (); + if (chars_read == 2 && strEQ (buf, ".\n")) + break; +@@ -2434,13 +2441,49 @@ + break; + } + } +-if (!pipefp) ++if (!tmpfp) + return; +-if (fwrite ("w\nq\n", sizeof (char), (size_t) 4, pipefp) == 0 +- || fflush (pipefp) != 0) ++if (fwrite ("w\nq\n", sizeof (char), (size_t) 4, tmpfp) == 0 ++ || fflush (tmpfp) != 0) + write_fatal (); +-if (pclose (pipefp) != 0) +- fatal ("%s FAILED", editor_program); ++ ++if (lseek (tmpfd, 0, SEEK_SET) == -1) ++ pfatal ("Can't rewind to the beginning of file %s", quotearg (tmpname)); ++ ++if (! dry_run && ! skip_rest_of_patch) { ++ int exclusive = *outname_needs_removal ? 0 : O_EXCL; ++ *outname_needs_removal = true; ++ if (inerrno != ENOENT) ++{ ++ *outname_needs_removal = true; ++ copy_file (inname, outname, 0, exclusive, instat.st_mode, true); ++} ++ sprintf (buf, "%s %s%s", editor_program, ++ verbosity == VERBOSE ? "" : "- ", ++ outname); ++ fflush (stdout); ++ ++ pid = fork(); ++ if (pid == -1) ++pfatal ("Can't fork"); ++ else if (pid == 0) ++{ ++ dup2 (tmpfd, 0); ++ execl ("/bin/sh", "sh
[arch-commits] Commit in patch/repos (3 files)
Date: Tuesday, September 25, 2018 @ 20:00:52 Author: jelle Revision: 335378 archrelease: copy trunk to extra-x86_64 Added: patch/repos/extra-x86_64/ patch/repos/extra-x86_64/CVE-2018-1000156.patch (from rev 335377, patch/trunk/CVE-2018-1000156.patch) patch/repos/extra-x86_64/PKGBUILD (from rev 335377, patch/trunk/PKGBUILD) + CVE-2018-1000156.patch | 142 +++ PKGBUILD | 61 2 files changed, 203 insertions(+) Copied: patch/repos/extra-x86_64/CVE-2018-1000156.patch (from rev 335377, patch/trunk/CVE-2018-1000156.patch) === --- extra-x86_64/CVE-2018-1000156.patch (rev 0) +++ extra-x86_64/CVE-2018-1000156.patch 2018-09-25 20:00:52 UTC (rev 335378) @@ -0,0 +1,142 @@ +diff -aur patch-2.7.6.old/src/pch.c patch-2.7.6/src/pch.c +--- patch-2.7.6.old/src/pch.c 2018-09-25 21:35:15.468805478 +0200 patch-2.7.6/src/pch.c 2018-09-25 21:39:33.691394951 +0200 +@@ -33,6 +33,7 @@ + # include + #endif + #include ++#include + + #define INITHUNKMAX 125 /* initial dynamic allocation size */ + +@@ -2388,22 +2389,28 @@ + static char const editor_program[] = EDITOR_PROGRAM; + + file_offset beginning_of_this_line; +-FILE *pipefp = 0; + size_t chars_read; ++FILE *tmpfp = 0; ++char const *tmpname; ++int tmpfd; ++pid_t pid; ++ ++if (! dry_run && ! skip_rest_of_patch) ++ { ++ /* Write ed script to a temporary file. This causes ed to abort on ++ invalid commands such as when line numbers or ranges exceed the ++ number of available lines. When ed reads from a pipe, it rejects ++ invalid commands and treats the next line as a new command, which ++ can lead to arbitrary command execution. */ ++ ++ tmpfd = make_tempfile (&tmpname, 'e', NULL, O_RDWR | O_BINARY, 0); ++ if (tmpfd == -1) ++pfatal ("Can't create temporary file %s", quotearg (tmpname)); ++ tmpfp = fdopen (tmpfd, "w+b"); ++ if (! tmpfp) ++pfatal ("Can't open stream for file %s", quotearg (tmpname)); ++ } + +-if (! dry_run && ! skip_rest_of_patch) { +- int exclusive = *outname_needs_removal ? 0 : O_EXCL; +- assert (! inerrno); +- *outname_needs_removal = true; +- copy_file (inname, outname, 0, exclusive, instat.st_mode, true); +- sprintf (buf, "%s %s%s", editor_program, +- verbosity == VERBOSE ? "" : "- ", +- outname); +- fflush (stdout); +- pipefp = popen(buf, binary_transput ? "wb" : "w"); +- if (!pipefp) +-pfatal ("Can't open pipe to %s", quotearg (buf)); +-} + for (;;) { + char ed_command_letter; + beginning_of_this_line = file_tell (pfp); +@@ -2414,14 +2421,14 @@ + } + ed_command_letter = get_ed_command_letter (buf); + if (ed_command_letter) { +- if (pipefp) +- if (! fwrite (buf, sizeof *buf, chars_read, pipefp)) ++ if (tmpfp) ++ if (! fwrite (buf, sizeof *buf, chars_read, tmpfp)) + write_fatal (); + if (ed_command_letter != 'd' && ed_command_letter != 's') { + p_pass_comments_through = true; + while ((chars_read = get_line ()) != 0) { +- if (pipefp) +- if (! fwrite (buf, sizeof *buf, chars_read, pipefp)) ++ if (tmpfp) ++ if (! fwrite (buf, sizeof *buf, chars_read, tmpfp)) + write_fatal (); + if (chars_read == 2 && strEQ (buf, ".\n")) + break; +@@ -2434,13 +2441,49 @@ + break; + } + } +-if (!pipefp) ++if (!tmpfp) + return; +-if (fwrite ("w\nq\n", sizeof (char), (size_t) 4, pipefp) == 0 +- || fflush (pipefp) != 0) ++if (fwrite ("w\nq\n", sizeof (char), (size_t) 4, tmpfp) == 0 ++ || fflush (tmpfp) != 0) + write_fatal (); +-if (pclose (pipefp) != 0) +- fatal ("%s FAILED", editor_program); ++ ++if (lseek (tmpfd, 0, SEEK_SET) == -1) ++ pfatal ("Can't rewind to the beginning of file %s", quotearg (tmpname)); ++ ++if (! dry_run && ! skip_rest_of_patch) { ++ int exclusive = *outname_needs_removal ? 0 : O_EXCL; ++ *outname_needs_removal = true; ++ if (inerrno != ENOENT) ++{ ++ *outname_needs_removal = true; ++ copy_file (inname, outname, 0, exclusive, instat.st_mode, true); ++} ++ sprintf (buf, "%s %s%s", editor_program, ++ verbosity == VERBOSE ? "" : "- ", ++ outname); ++ fflush (stdout); ++ ++ pid = fork(); ++ if (pid == -1) ++pfatal ("Can't fork"); ++ else if (pid == 0) ++{ ++ dup2 (tmpfd, 0); ++ execl ("/bin/sh", "sh", "-c", buf, (char *) 0);
[arch-commits] Commit in patch/repos (3 files)
Date: Tuesday, February 13, 2018 @ 15:18:57 Author: seblu Revision: 316799 db-move: moved patch from [testing] to [core] (x86_64) Added: patch/repos/core-x86_64/PKGBUILD (from rev 316798, patch/repos/testing-x86_64/PKGBUILD) Deleted: patch/repos/core-x86_64/PKGBUILD patch/repos/testing-x86_64/ --+ /PKGBUILD| 51 + core-x86_64/PKGBUILD | 45 --- 2 files changed, 51 insertions(+), 45 deletions(-) Deleted: core-x86_64/PKGBUILD === --- core-x86_64/PKGBUILD2018-02-13 14:10:50 UTC (rev 316798) +++ core-x86_64/PKGBUILD2018-02-13 15:18:57 UTC (rev 316799) @@ -1,45 +0,0 @@ -# $Id$ -# Maintainer: Sébastien Luttringer -# Contributor: Allan McRae -# Contributor: judd - -pkgname=patch -pkgver=2.7.5 -pkgrel=1 -pkgdesc='A utility to apply patch files to original sources' -arch=('i686' 'x86_64') -url='http://www.gnu.org/software/patch/patch.html' -license=('GPL') -groups=('base-devel') -depends=('glibc' 'attr') -makedepends=('ed') -optdepends=('ed: for patch -e functionality') -validpgpkeys=('7768CE4B75E5236F1A374CEEC4C927CD5D1B36D7') # Andreas Gruenbacher -source=("ftp://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.xz"{,.sig}) -md5sums=('e3da7940431633fb65a01b91d3b7a27a' - 'SKIP') - -#prepare() { -# # Fix segfault on non-numeric strip-count -# # (also segfaults on nonexistent directory passed to -d) -# # http://savannah.gnu.org/bugs/?37500 -# patch -Np1 -d $pkgname-$pkgver < patch-2.7.1-initialize-data-structures-early-enough.patch -#} - -build() { - cd $pkgname-$pkgver - ./configure --prefix=/usr - make -} - -check() { - cd $pkgname-$pkgver - make check -} - -package() { - cd $pkgname-$pkgver - make DESTDIR="$pkgdir" install -} - -# vim:set ts=2 sw=2 et: Copied: patch/repos/core-x86_64/PKGBUILD (from rev 316798, patch/repos/testing-x86_64/PKGBUILD) === --- core-x86_64/PKGBUILD(rev 0) +++ core-x86_64/PKGBUILD2018-02-13 15:18:57 UTC (rev 316799) @@ -0,0 +1,51 @@ +# $Id$ +# Maintainer: Sébastien Luttringer +# Contributor: Allan McRae +# Contributor: judd + +pkgname=patch +pkgver=2.7.6 +pkgrel=1 +pkgdesc='A utility to apply patch files to original sources' +arch=('x86_64') +url='https://www.gnu.org/software/patch/' +license=('GPL') +groups=('base-devel') +depends=('glibc' 'attr') +makedepends=('ed') +optdepends=('ed: for patch -e functionality') +validpgpkeys=('259B3792B3D6D319212CC4DCD5BF9FEB0313653A') # Andreas Gruenbacher +source=("https://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.xz"{,.sig}) +md5sums=('78ad9937e4caadcba1526ef1853730d5' + 'SKIP') + +prepare() { + cd $pkgname-$pkgver + # apply patch from the source array (should be a pacman feature) + local filename + for filename in "${source[@]}"; do +if [[ "$filename" =~ \.patch$ ]]; then + msg2 "Applying patch ${filename##*/}" + patch -p1 -N -i "$srcdir/${filename##*/}" +fi + done + : +} + +build() { + cd $pkgname-$pkgver + ./configure --prefix=/usr + make +} + +check() { + cd $pkgname-$pkgver + make check +} + +package() { + cd $pkgname-$pkgver + make DESTDIR="$pkgdir" install +} + +# vim:set ts=2 sw=2 et: