Artifacts Associated With Ticket 442636ffffffffff
Ticket change [4b2081c008] (rid 126644) by lloydlim on 2001-07-19 01:38:24:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
The following warning is produced when compiling Tcl on later versions of Linux and FreeBSD: /tmp/video4_Linux_2.2.19-7.0.1/mash-code/tcl8.3/unix/libtcl8.3.a(tclUnixPipe.o): In function `TclpCreateTempFile': tclUnixPipe.o(.text+0xef): the use of `tmpnam' is dangerous, better use `mkstemp' Comments in tclUnixPipe.c say "Linux says we should use mkstemp, but Solaris prefers tmpnam.". Please note that Solaris does _not_ prefer tmpnam, it prefers tmpfile (which is more similar to mkstemp than to tmpnam). This preference is just because tmpfile cleans up after itself. There is nothing wrong with mkstemp on Solaris. On the other hand, the use of tmpnam on Linux and FreeBSD is a security issue and generates a compile time warning. Therefore, I recommend that Tcl switch to using mkstemp. Here is a patch to replace tmpnam with mkstemp: --- tclUnixPipe.c.old Wed Jul 18 16:12:31 2001 +++ tclUnixPipe.c Wed Jul 18 17:50:34 2001 @@ -186,19 +186,21 @@ TclpCreateTempFile(contents) CONST char *contents; /* String to write into temp file, or NULL. */ { - char fileName[L_tmpnam], *native; + char fileName[L_tmpnam + 9], *native; Tcl_DString dstring; int fd; /* - * Linux says we should use mkstemp, but Solaris prefers tmpnam. - * We should also check against making more then TMP_MAX of these. + * We should check against making more than TMP_MAX of these. */ - if (tmpnam(fileName) == NULL) { /* INTL: Native. */ - return NULL; + strcpy(fileName, P_tmpdir); + if (fileName[strlen(fileName) - 1] != '/') { + strcat(fileName, "/"); } - fd = open(fileName, O_RDWR|O_CREAT|O_EXCL, 0666); /* INTL: Native. */ + strcat(fileName, "tclXXXXXX"); + fd = mkstemp(fileName); /* INTL: Native. */ if (fd == -1) { return NULL; } - foundin initialized to: "obsolete: 8.3.3"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "lloydlim"
- subsystem initialized to: "52. Portability Support"
- title initialized to: "use of `tmpnam' is dangerous"
- type initialized to: "Bug"
Ticket change [f34cba73ec] (rid 129686) by hobbs on 2001-07-20 05:26:59:
- assignee changed to: "hobbs"
Ticket change [08eb3dcbe5] (rid 89640) by hobbs on 2001-08-07 06:14:14:
- closedate changed to: "2001-08-06T23:14:14"
- closer changed to: "hobbs"
- icomment:
Logged In: YES user_id=72656 fixed in 8.4a3 cvs.
- login: "hobbs"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "hobbs"