Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Oct 1995 16:33:15 +0100 (MET)
From:      J Wunsch <j@uriah.heep.sax.de>
To:        kedron@tribe.com
Cc:        bugs@freebsd.org
Subject:   Re: 2.0.5 mktemp bug.
Message-ID:  <199510281533.QAA06414@uriah.heep.sax.de>
In-Reply-To: <199510271912.FAA24825@godzilla.zeta.org.au> from "Bruce Evans" at Oct 28, 95 05:12:01 am

next in thread | previous in thread | raw e-mail | index | archive | help
As Bruce Evans wrote:
> 
> You should copy the string constant to a suitable large non-const
             ^^^^
> array, e.g., `char foo[32]'.

...or initialize a variable with it:

static char template[] = "/tmp/fooXXXXX";
...
	mktemp(template);

It depends on the application which variant is more appropriate.

Btw., this has *not* been the expected behaviour in the pre-ANSI era,
so if you're porting a very old program, you could sometimes stumple
across this problem.  That's why "gcc -traditional" doesn't make
constant strings read/only, but you're strongly encouraged to do the
right thing instead of relying on this hack.

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199510281533.QAA06414>