Bugzilla – Attachment 51584 Details for
Bug 120577
texinfo: insecure tmp file handling
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
Replace mkstemp with mkdtemp
texinfo-4.8-tempfile.patch (text/plain), 1.94 KB, created by
Dr. Werner Fink
on 2005-10-06 11:40:06 UTC
(
hide
)
Description:
Replace mkstemp with mkdtemp
Filename:
MIME Type:
Creator:
Dr. Werner Fink
Created:
2005-10-06 11:40:06 UTC
Size:
1.94 KB
patch
obsolete
>--- util/texindex.c >+++ util/texindex.c 2005-10-06 12:48:09.000000000 +0200 >@@ -20,6 +20,7 @@ > > #include "system.h" > #include <getopt.h> >+#include <stdlib.h> > > static char *program_name = "texindex"; > >@@ -37,8 +38,6 @@ > #define memset(ptr, ignore, count) bzero (ptr, count) > #endif > >-char *mktemp (char *); >- > #if !defined (SEEK_SET) > # define SEEK_SET 0 > # define SEEK_CUR 1 >@@ -99,6 +98,10 @@ > /* Directory to use for temporary files. On Unix, it ends with a slash. */ > char *tempdir; > >+/* The base directory for the temporary files located in tempdir */ >+ >+static char *tempbase = NULL; >+ > /* Number of last temporary file. */ > int tempcount; > >@@ -146,6 +149,7 @@ > void *xmalloc (), *xrealloc (); > char *concat (char *s1, char *s2); > void flush_tempfiles (int to_count); >+void flush_tempfiles_atexit (); > > #define MAX_IN_CORE_SORT 500000 > >@@ -321,6 +325,7 @@ > tempdir = concat (tempdir, "/"); > > keep_tempfiles = 0; >+ atexit(flush_tempfiles_atexit); > > /* Allocate ARGC input files, which must be enough. */ > >@@ -384,25 +389,25 @@ > usage (1); > } > >+ > /* Return a name for temporary file COUNT. */ > > static char * > maketempname (int count) > { >- static char *tempbase = NULL; >- char tempsuffix[10]; >+ char tempsuffix[20]; > > if (!tempbase) > { >- int fd; >- tempbase = concat (tempdir, "txidxXXXXXX"); >+ char *td; >+ tempbase = concat (tempdir, "txdirXXXXXX"); > >- fd = mkstemp (tempbase); >- if (fd == -1) >+ td = mkdtemp (tempbase); >+ if (td == (char*)0) > pfatal_with_name (tempbase); > } > >- sprintf (tempsuffix, ".%d", count); >+ sprintf (tempsuffix, "/txidx.%d", count); > return concat (tempbase, tempsuffix); > } > >@@ -418,6 +423,13 @@ > unlink (maketempname (++last_deleted_tempcount)); > } > >+void >+flush_tempfiles_atexit (void) >+{ >+ flush_tempfiles (tempcount); >+ if (tempbase) >+ (void)rmdir(tempbase); >+} > > /* Compare LINE1 and LINE2 according to the specified set of keyfields. */ >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
Attachments on
bug 120577
: 51584