This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: libiberty/choose_temp.c replace mktemp with mkstemp


The call of mktemp() is considered as a potential security risk. Thus,
the following patch replaces it with mkstemp in the file
libiberty/choose-temp.c. After applying the appended patch, I
bootstrapped the compiler and ran the testsuites. There were no regressions. 

Peter Schmid

2001-02-28  Peter Schmid  <schmid@snake.iap.physik.tu-darmstadt.de>

	* choose-temp.c (choose_temp_base): Replace mktemp with mkstemp

*** libiberty/choose-temp.c.orig	Tue Feb 27 22:57:02 2001
--- libiberty/choose-temp.c	Tue Feb 27 23:03:44 2001
*************** choose_temp_base ()
*** 137,145 ****
      temp_filename[len++] = DIR_SEPARATOR;
    strcpy (temp_filename + len, TEMP_FILE);
  
!   mktemp (temp_filename);
!   if (strlen (temp_filename) == 0)
!     abort ();
    return temp_filename;
  }
  /* Return a temporary file name (as a string) or NULL if unable to create
--- 137,144 ----
      temp_filename[len++] = DIR_SEPARATOR;
    strcpy (temp_filename + len, TEMP_FILE);
  
!   if (mkstemp (temp_filename) == -1)
!       abort ();
    return temp_filename;
  }
  /* Return a temporary file name (as a string) or NULL if unable to create


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]