Re: tmpfile alternative

From: Jarno Huuskonen (Jarno.Huuskonenat_private)
Date: Thu Jan 03 2002 - 12:34:32 PST

  • Next message: Giorgio Zoppi: "Re: tmpfile alternative"

    Hi,
    
    First of all why do you need to write your own copy of mkstemp ?
    (see http://lwn.net/2000/1221/a/sec-tmp.php3)
    
    On Thu, Jan 03, Giorgio Zoppi wrote:
    [cut]
    
    >       while (count < 9)
    
    is 9 always less than MAX_BUFF ? Possibility for overflow.
    
    > 	{
    > 	  fread (&num, sizeof (unsigned int), 1, urand_file);
    
    Why don't you check for read errors ? If the reads from urand_file fail
    then the filename is not going to be very random.
    
    > 	  stream[count] = (char) num;
    > 	  count++;
    > 	}
    >       base64_encode (&b, stream, 9);
    >       
    >       memset (filename, '\0', sizeof (filename)-1);
    >       mypid = (int) getpid();
    >       snprintf (filename, sizeof (filename), "%s-%d-%s", appname, mypid, b.data);
    >     }
    [cut]
    
    >   if ((tmp = fdopen (fd, "r+b")) == NULL)
    
    Are you going to write to to temp file (you open the file as readonly) ?
    
    -- 
    Jarno Huuskonen - System Administrator   |  Jarno.Huuskonenat_private
    



    This archive was generated by hypermail 2b30 : Thu Jan 03 2002 - 14:59:49 PST