Skip to content
Tcl Source Code History Of Ticket 442636ffffffffffffffffffffffffffffffffff
Login

History Of Ticket 442636ffffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 442636ffffffffffffffffffffffffffffffffff

  1. Ticket change [4b2081c008] (rid 126644) by lloydlim on 2001-07-19 01:38:24:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. 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;
           }
      
      
    4. foundin initialized to: "obsolete: 8.3.3"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "lloydlim"
    9. subsystem initialized to: "52. Portability Support"
    10. title initialized to: "use of `tmpnam' is dangerous"
    11. type initialized to: "Bug"
  2. Ticket change [f34cba73ec] (rid 129686) by hobbs on 2001-07-20 05:26:59:

    1. assignee changed to: "hobbs"
  3. Ticket change [08eb3dcbe5] (rid 89640) by hobbs on 2001-08-07 06:14:14:

    1. closedate changed to: "2001-08-06T23:14:14"
    2. closer changed to: "hobbs"
    3. icomment:
      Logged In: YES 
      user_id=72656
      
      fixed in 8.4a3 cvs.
      
      
    4. login: "hobbs"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "hobbs"