linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* mktemp()
@ 2004-06-05  3:30 Progga
  2004-06-05  4:55 ` mktemp() Glynn Clements
  2004-06-06  9:50 ` mktemp() Martin Olsson
  0 siblings, 2 replies; 9+ messages in thread
From: Progga @ 2004-06-05  3:30 UTC (permalink / raw)
  To: linux-c-programming



 Is mktemp() a deprecated function ?  The compiler ( actually the linker ) is 
repeatedly shouting -

 "warning: mktemp() possibly used unsafely; consider using mkstemp()"


 The manpage of mktemp(3) states -

-------
A common problem that results in a core dump is that the programmer
passes in a read-only string to mktemp(), mkstemp(), mkstemps() or
mkdtemp().
------

 - and I have taken care of this.


 The manpage also says -

------
BUGS
     This family of functions produces filenames which can be guessed, though
     the risk is minimized when large numbers of `Xs' are used to increase the
     number of possible temporary filenames.  This makes the race in mktemp(),
     between testing for a file's existence (in the mktemp() function call)
     and opening it for use (later in the user application) particularly dan-
     gerous from a security perspective.  Whenever it is possible, mkstemp()
     should be used instead, since it does not have the race condition.  If
     mkstemp() cannot be used, the filename created by mktemp() should be cre-
     ated using the O_EXCL flag to open(2) and the return status of the call
     should be tested for failure.  This will ensure that the program does not
     continue blindly in the event that an attacker has already created the
     file with the intention of manipulating or reading its contents.
------

 I haven't used open() and hence there's no O_EXCL.  Is it causing the warning ?
I also can't understand how an attacker can dupe the process into writing in
his intended file since mktemp() is supposed to return those names only that are
currently UNUSED.



 Khoda Hafez
 Progga




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

end of thread, other threads:[~2004-06-06  9:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-05  3:30 mktemp() Progga
2004-06-05  4:55 ` mktemp() Glynn Clements
2004-06-05  8:17   ` mktemp() Progga
2004-06-05 11:16     ` mktemp() Jan-Benedict Glaw
2004-06-05 12:40       ` mktemp() Progga
2004-06-05 13:18         ` mktemp() Jan-Benedict Glaw
2004-06-05 19:42     ` mktemp() Glynn Clements
2004-06-05 22:43       ` mktemp() Progga
2004-06-06  9:50 ` mktemp() Martin Olsson

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 NNTP newsgroup(s).