Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 106105 | Differences between
and this patch

Collapse All | Expand All

(-)util/texindex.c (-12 / +19 lines)
Lines 99-104 long nlines; Link Here
99
/* Directory to use for temporary files.  On Unix, it ends with a slash.  */
99
/* Directory to use for temporary files.  On Unix, it ends with a slash.  */
100
char *tempdir;
100
char *tempdir;
101
101
102
/* Basename for temp files inside of tempdir.  */
103
char *tempbase;
104
102
/* Number of last temporary file.  */
105
/* Number of last temporary file.  */
103
int tempcount;
106
int tempcount;
104
107
Lines 190-195 main (int argc, char **argv) Link Here
190
193
191
  decode_command (argc, argv);
194
  decode_command (argc, argv);
192
195
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
193
  /* Process input files completely, one by one.  */
201
  /* Process input files completely, one by one.  */
194
202
195
  for (i = 0; i < num_infiles; i++)
203
  for (i = 0; i < num_infiles; i++)
Lines 392-412 For more information about these matters Link Here
392
static char *
400
static char *
393
maketempname (int count)
401
maketempname (int count)
394
{
402
{
395
  static char *tempbase = NULL;
396
  char tempsuffix[10];
403
  char tempsuffix[10];
397
404
  char *name, *tmp_name;
398
  if (!tempbase)
405
  int fd;
399
    {
400
      int fd;
401
      tempbase = concat (tempdir, "txidxXXXXXX");
402
403
      fd = mkstemp (tempbase);
404
      if (fd == -1)
405
        pfatal_with_name (tempbase);
406
    }
407
406
408
  sprintf (tempsuffix, ".%d", count);
407
  sprintf (tempsuffix, ".%d", count);
409
  return concat (tempbase, tempsuffix);
408
  tmp_name = concat (tempdir, tempbase);
409
  name = concat (tmp_name, tempsuffix);
410
  free(tmp_name);
411
412
  fd = mkstemp (name);
413
  if (fd == -1)
414
    pfatal_with_name (name);
415
416
  return name;
410
}
417
}
411
418
412
419

Return to bug 106105