root/trunk/texinfo/texinfo-4.8-tempfile_fix-1.patch

Revision 1184, 2.0 kB (checked in by archaic, 3 years ago)

Added texinfo patch to fix temp file creation.

  • texinfo-4.8/util/texindex.c

    old new  
    9999/* Directory to use for temporary files.  On Unix, it ends with a slash.  */ 
    100100char *tempdir; 
    101101 
     102/* Basename for temp files inside of tempdir.  */ 
     103char *tempbase; 
     104 
    102105/* Number of last temporary file.  */ 
    103106int tempcount; 
    104107 
     
    190193 
    191194  decode_command (argc, argv); 
    192195 
     196  /* XXX mkstemp not appropriate, as we need to have somewhat predictable 
     197   * names. But race condition was fixed, see maketempname.  
     198   */ 
     199  tempbase = mktemp ("txidxXXXXXX"); 
     200 
    193201  /* Process input files completely, one by one.  */ 
    194202 
    195203  for (i = 0; i < num_infiles; i++) 
     
    389397static char * 
    390398maketempname (int count) 
    391399{ 
    392   static char *tempbase = NULL; 
    393400  char tempsuffix[10]; 
    394  
    395   if (!tempbase) 
    396     { 
    397       int fd; 
    398       tempbase = concat (tempdir, "txidxXXXXXX"); 
    399  
    400       fd = mkstemp (tempbase); 
    401       if (fd == -1) 
    402         pfatal_with_name (tempbase); 
    403     } 
     401  char *name, *tmp_name; 
     402  int fd; 
    404403 
    405404  sprintf (tempsuffix, ".%d", count); 
    406   return concat (tempbase, tempsuffix); 
     405  tmp_name = concat (tempdir, tempbase); 
     406  name = concat (tmp_name, tempsuffix); 
     407  free(tmp_name); 
     408 
     409  fd = open (name, O_CREAT|O_EXCL|O_WRONLY, 0600); 
     410  if (fd == -1) 
     411    pfatal_with_name (name); 
     412 
     413  close(fd); 
     414  return name; 
    407415} 
    408416 
    409417 
Note: See TracBrowser for help on using the browser.