Return to BSD News archive
Newsgroups: comp.os.386bsd.bugs Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!spool.mu.edu!cass.ma02.bull.com!syd.bull.oz.au!melb.bull.oz.au!zen!sjg From: sjg@zen.void.oz.au (Simon J. Gerraty) Subject: Re: mktemp() crashes Organization: Zen programming... References: <CF7snJ.ID9@dvorak.amd.com> <1993Oct21.093717.2658@zen.void.oz.au> <1993Oct21.120854.2900@zen.void.oz.au> <JKH.93Oct25234522@whisker.lotus.ie> Message-ID: <1993Oct27.140344.16100@zen.void.oz.au> Date: Wed, 27 Oct 1993 14:03:44 GMT Lines: 34 jkh@whisker.lotus.ie (Jordan K. Hubbard) writes: >In article <1993Oct21.120854.2900@zen.void.oz.au> sjg@zen.void.oz.au (Simon J. Gerraty) writes: > The following patch modifes mktemp() to use a private (static) > buffer which it can safely modify. >BLETCH!! Oops he's right. >... That's no fix at all! Please don't apply it, anyone. >Repeated calls to mktemp() will not DTRT, not to mention the fact that The problem with the patch has nothing to do with repeated calls (which work fine). There is however a problem in that correctly written programs that do: strcpy(buf, "/tmp/fooXXXXXXX"); mktemp(buf); /* ignores return value, relies on buf being modified */ fd = open(buf, ...); would be broken. And there are quite a few cases in /usr/src/* So, jkh's reasoning may be off but he's correct - you cannot safely change the behaviour of mktemp(). Sorry... stick to -traditional or fix all your programs that call mktemp("/tmp/fooXXXX") -- Simon J. Gerraty <sjg@zen.void.oz.au> #include <disclaimer> /* imagine something _very_ witty here */