[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Some fixes to the CAN-2005-3011 texindex changes
From: |
Miloslav Trmac |
Subject: |
[PATCH] Some fixes to the CAN-2005-3011 texindex changes |
Date: |
Mon, 09 Oct 2006 19:35:05 +0200 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20061004) |
Hello,
the attached patch against current CVS:
- splits maketempname() to two functions, with gettempname() not
trying to create the file. Currently the maketempname() calls
in flush_tempfiles() return NULL and temporary files are not
removed at all.
- adds a missing check of maketempname() return value to sort_offline()
Mirek
Index: util/texindex.c
===================================================================
RCS file: /sources/texinfo/texinfo/util/texindex.c,v
retrieving revision 1.15
diff -c -r1.15 texindex.c
*** util/texindex.c 5 Oct 2005 23:21:41 -0000 1.15
--- util/texindex.c 9 Oct 2006 17:34:22 -0000
***************
*** 395,411 ****
usage (1);
}
/* Return a name for temporary file COUNT, or NULL if failure. */
static char *
maketempname (int count)
{
- char tempsuffix[10];
char *name;
int fd;
! sprintf (tempsuffix, ".%d", count);
! name = concat3 (tempdir, tempbase, tempsuffix);
fd = open (name, O_CREAT|O_EXCL|O_WRONLY, 0600);
if (fd == -1)
return NULL;
--- 395,420 ----
usage (1);
}
+ /* Return a name for temporary file COUNT. It is INSECURE to use this name to
+ create files without O_EXCL. */
+ static char *
+ gettempname (int count)
+ {
+ char tempsuffix[10];
+
+ sprintf (tempsuffix, ".%d", count);
+ return concat3 (tempdir, tempbase, tempsuffix);
+ }
+
/* Return a name for temporary file COUNT, or NULL if failure. */
static char *
maketempname (int count)
{
char *name;
int fd;
! name = gettempname (count);
fd = open (name, O_CREAT|O_EXCL|O_WRONLY, 0600);
if (fd == -1)
return NULL;
***************
*** 425,431 ****
if (keep_tempfiles)
return;
while (last_deleted_tempcount < to_count)
! unlink (maketempname (++last_deleted_tempcount));
}
--- 434,440 ----
if (keep_tempfiles)
return;
while (last_deleted_tempcount < to_count)
! unlink (gettempname (++last_deleted_tempcount));
}
***************
*** 893,901 ****
for (i = 0; i < ntemps; i++)
{
char *outname = maketempname (++tempcount);
! FILE *ostream = fopen (outname, "w");
long tempsize = 0;
if (!ostream)
pfatal_with_name (outname);
tempfiles[i] = outname;
--- 902,913 ----
for (i = 0; i < ntemps; i++)
{
char *outname = maketempname (++tempcount);
! FILE *ostream;
long tempsize = 0;
+ if (!outname)
+ pfatal_with_name("temp file");
+ ostream = fopen (outname, "w");
if (!ostream)
pfatal_with_name (outname);
tempfiles[i] = outname;
- [PATCH] Some fixes to the CAN-2005-3011 texindex changes,
Miloslav Trmac <=