unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Warning on 'mktemp' [Cygwin]
@ 2010-05-23 11:58 Angelo Graziosi
  2010-05-23 12:25 ` Florian Weimer
  0 siblings, 1 reply; 2+ messages in thread
From: Angelo Graziosi @ 2010-05-23 11:58 UTC (permalink / raw)
  To: Emacs

On Cygwin I find this warning:

[...]
/tmp/emacs/lib-src/movemail.c: In function ‘main’:
/tmp/emacs/lib-src/movemail.c:305: warning: call to ‘mktemp’ declared 
with attribute warning: the use of `mktemp' is dangerous; use `mkstemp' 
instead
[...]

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?

Thanks,
Angelo.



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Warning on 'mktemp' [Cygwin]
  2010-05-23 11:58 Warning on 'mktemp' [Cygwin] Angelo Graziosi
@ 2010-05-23 12:25 ` Florian Weimer
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Weimer @ 2010-05-23 12:25 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: Emacs

* 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.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-23 12:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-23 11:58 Warning on 'mktemp' [Cygwin] Angelo Graziosi
2010-05-23 12:25 ` Florian Weimer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).