mirror of
https://https.git.savannah.gnu.org/git/patch.git
synced 2026-01-27 09:54:55 +00:00
Stop using mktemp() for TMPINNAME
* src/inp.c (plan_b): Compute TMPINNAME with make_tempfile() if needed instead of precomputing it in src/patch.c (main).
This commit is contained in:
parent
4b6267d62f
commit
51147ca57d
@ -9,6 +9,9 @@
|
||||
* bootstrap.conf: Use the gnulib tempname module.
|
||||
* src/util.c (make_tempfile): New function.
|
||||
|
||||
* src/inp.c (plan_b): Compute TMPINNAME 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.
|
||||
|
||||
16
src/inp.c
16
src/inp.c
@ -353,16 +353,22 @@ plan_b (char const *filename)
|
||||
char const *rev;
|
||||
size_t revlen;
|
||||
lin line = 1;
|
||||
int exclusive;
|
||||
|
||||
if (instat.st_size == 0)
|
||||
filename = NULL_DEVICE;
|
||||
if (! (ifp = fopen (filename, binary_transput ? "rb" : "r")))
|
||||
pfatal ("Can't open file %s", quotearg (filename));
|
||||
exclusive = TMPINNAME_needs_removal ? 0 : O_EXCL;
|
||||
TMPINNAME_needs_removal = 1;
|
||||
tifd = create_file (TMPINNAME, O_RDWR | O_BINARY | exclusive, (mode_t) 0,
|
||||
true);
|
||||
if (TMPINNAME_needs_removal)
|
||||
{
|
||||
/* Reopen the existing temporary file. */
|
||||
tifd = create_file (TMPINNAME, O_RDWR | O_BINARY, 0, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
tifd = make_tempfile (&TMPINNAME, 'i', NULL, O_RDWR | O_BINARY,
|
||||
S_IRUSR | S_IWUSR);
|
||||
TMPINNAME_needs_removal = 1;
|
||||
}
|
||||
i = 0;
|
||||
len = 0;
|
||||
maxlen = 1;
|
||||
|
||||
@ -140,7 +140,6 @@ main (int argc, char **argv)
|
||||
/* Cons up the names of the global temporary files.
|
||||
Do this before `cleanup' can possibly be called (e.g. by `pfatal'). */
|
||||
TMPOUTNAME = make_temp ('o');
|
||||
TMPINNAME = make_temp ('i');
|
||||
TMPREJNAME = make_temp ('r');
|
||||
TMPPATNAME = make_temp ('p');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user