From owner-freebsd-current Sun Oct 20 19:57:51 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id TAA15005 for current-outgoing; Sun, 20 Oct 1996 19:57:51 -0700 (PDT) Received: from scanner.worldgate.com (scanner.worldgate.com [198.161.84.3]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id TAA14996 for ; Sun, 20 Oct 1996 19:57:46 -0700 (PDT) Received: from znep.com (uucp@localhost) by scanner.worldgate.com (8.7.5/8.7.3) with UUCP id UAA06575; Sun, 20 Oct 1996 20:57:13 -0600 (MDT) Received: from localhost (marcs@localhost) by alive.ampr.ab.ca (8.7.5/8.7.3) with SMTP id UAA22396; Sun, 20 Oct 1996 20:56:38 -0600 (MDT) Date: Sun, 20 Oct 1996 20:56:37 -0600 (MDT) From: Marc Slemko X-Sender: marcs@alive.ampr.ab.ca To: Ron Bolin cc: freebsd-current@FreeBSD.org Subject: Re: mktemp BUG? In-Reply-To: <326AD788.167EB0E7@mindspring.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-current@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk Check the man page for mktemp: >NOTES > A common problem that results in a core dump is that the programmer pass- > es in a read-only string to mktemp() or mkstemp(). This is common with > programs that were developed before ISO 9899: 1990 (``ISO C'') compilers > were common. For example, calling mkstemp() with an argument of > "/tmp/tempfile.XXXXXX" will result in a core dump due to mkstemp() at- > tempting to modify the string constant that was given. If the program in > question makes heavy use of that type of function call, you do have the > option of compiling the program so that it will store string constants in > a writable segment of memory. See gcc(1) for more information. Try something like: #include #include int main () { char *tmp; char filename[80]; strcpy(filename, "/tmp/cp.XXXXX"); tmp = mktemp(filename); printf("file: %s (%p, %p)\n", tmp, tmp, filename); return 0; } Yes, mktemp is a bit strange. On Sun, 20 Oct 1996, Ron Bolin wrote: > Just checking my system and sanity. The mktemp(char *) function > dumps core everytime. Seems to be a problem in the C lib version. > Can anyone else duplicate this bug? > #include > char *tmp = mktemp("/tmp/cp.XXXXXX");