Re: Warnings while compiling Samba

From: Peter Pentchev (roam@orbitel.bg)
Date: 05/15/01


Date: Tue, 15 May 2001 17:02:21 +0300
From: Peter Pentchev <roam@orbitel.bg>
To: Axel Scheepers <axel@beheer2.iae.nl>

On Tue, May 15, 2001 at 03:51:31PM +0200, Axel Scheepers wrote:
> Well, man mkstemp brings me the the man page of mkstemp so I guess i'ts save
> to just replace the mktemp call with mkstemp. I don't have the time right now
> to look into the source so I can't be 100% sure about this... anyone?

'man mkstemp' brings up the manual page for mktemp(3), mkstemp(3), mkstemps(3)
and mkdtemp(3) functions. Just one look at the prototypes, though, should
tell you that the mktemp() and mkstemp() functions are NOT equivalent -
mktemp() returns a char *, mkstemp() returns an int.

Further down the manpage describes that mktemp() and mkstemp() really do
return different objects - mktemp() returns the filename of the new file
(which it does not create), mkstemp() actually creates the file and returns
a file descriptor.

It is only with difficulty that I can imagine a situation in which
the mkstemp() return value could be used as if it were returned by mktemp() -
programs using mktemp() expect a pointer to a string, while mkstemp() returns
a small integer. An attempt to create a file with that "name" would most
probably result in an immediate segmentation fault or bus error.

G'luck,
Peter

-- 
What would this sentence be like if pi were 3?
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-security" in the body of the message


Relevant Pages

  • Building gcc for powerpc
    ... # As I am building cross toolchain for ppc 8xx CPU. ... # Error file shows the following: ... the use of `mktemp' is dangerous, better use `mkstemp' ...
    (comp.os.linux.embedded)
  • Re: change to ee.c
    ... mkstemp returns a file descriptor rather than a string ... pointer, therefore, the subsequent openwould have undefined behavior. ... It looks like that we actually want fd = mkstemp() here. ...
    (freebsd-hackers)
  • Re: Warnings while compiling Samba
    ... trying to read the manpage in 10secs and then shouting out it should be same ... man mkstemp brings me the the man page of mkstemp so I guess i'ts save ... >> to just replace the mktemp call with mkstemp. ...
    (FreeBSD-Security)
  • Re: mktemp is dangerous, ifort
    ... Is there any thing I can do with respect to mktemp and mkstemp? ... Notice that this is simply a warning. ...
    (comp.lang.fortran)
  • mktemp is dangerous, ifort
    ... : warning: the use of `mktemp' is dangerous, ... Is there any thing I can do with respect to mktemp and mkstemp? ...
    (comp.lang.fortran)