[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Warning on 'mktemp' [Cygwin]
From: |
Florian Weimer |
Subject: |
Re: Warning on 'mktemp' [Cygwin] |
Date: |
Sun, 23 May 2010 14:25:49 +0200 |
* Angelo Graziosi:
> Note that 'configure' says: "checking for mkstemp... yes", so I have
> applied this patch:
>
> ================
> $ cat movemail.c.patch
> --- movemail.c.orig 2010-04-02 23:54:26.000000000 +0200
> +++ movemail.c 2010-05-23 12:35:06.296875000 +0200
> @@ -302,7 +302,7 @@
> p--;
> *p = 0;
> strcpy (p, "EXXXXXX");
> - mktemp (tempname);
> + mkstemp (tempname);
> unlink (tempname);
>
> while (1)
> ================
>
> and the warning disappeared. But is it safe apply it, at least locally
> on Cygwin?
mkstemp returns a file descriptor which you have to close. And you
must not unlink the file, otherwise the behavior is as bad as
mktemp() because the race is still there.