summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2010-09-14 16:20:59 +0200
committerAndreas Gruenbacher <agruen@suse.de>2010-09-17 01:51:50 +0200
commit76649aba9e1a6f191684480994114a57a5ddee0c (patch)
tree64d1cfc49b2694c923354a74d475c3c535a11a13
parent51147ca57dde618fc348b0fab3902f21007da644 (diff)
downloadpatch-76649aba9e1a6f191684480994114a57a5ddee0c.tar.gz
Stop using mktemp() for TMPPATNAME
* src/pch.c (open_patch_file): Compute TMPPATNAME with make_tempfile() if needed instead of precomputing it in src/patch.c (main).
-rw-r--r--ChangeLog3
-rw-r--r--src/patch.c1
-rw-r--r--src/pch.c9
3 files changed, 6 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 19af831..6221c53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,9 @@
* src/inp.c (plan_b): Compute TMPINNAME with make_tempfile() if needed
instead of precomputing it in src/patch.c (main).
+ * src/pch.c (open_patch_file): Compute TMPPATNAME with make_tempfile()
+ if needed instead of precomputing it in src/patch.c (main).
+
2010-07-27 Tim Waugh <twaugh@redhat.com>
* src/patch.c: Stops "patch --get 1" from segfaulting.
diff --git a/src/patch.c b/src/patch.c
index 8f1a03a..189a5a7 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -141,7 +141,6 @@ main (int argc, char **argv)
Do this before `cleanup' can possibly be called (e.g. by `pfatal'). */
TMPOUTNAME = make_temp ('o');
TMPREJNAME = make_temp ('r');
- TMPPATNAME = make_temp ('p');
/* parse switches */
Argc = argc;
diff --git a/src/pch.c b/src/pch.c
index a87f9cd..e51e73e 100644
--- a/src/pch.c
+++ b/src/pch.c
@@ -128,13 +128,10 @@ open_patch_file (char const *filename)
else
{
size_t charsread;
- int exclusive = TMPPATNAME_needs_removal ? 0 : O_EXCL;
+ int fd = make_tempfile (&TMPPATNAME, 'p', NULL, O_RDWR | O_BINARY, 0);
TMPPATNAME_needs_removal = 1;
- pfp = fdopen (create_file (TMPPATNAME,
- O_RDWR | O_BINARY | exclusive,
- (mode_t) 0, true),
- "w+b");
- if (!pfp)
+ pfp = fdopen (fd, "w+b");
+ if (! pfp)
pfatal ("Can't open stream for file %s", quotearg (TMPPATNAME));
for (st.st_size = 0;
(charsread = fread (buf, 1, bufsize, stdin)) != 0;