Fix CID 39919 Insecure temporary file.

This commit is contained in:
Renaud 2015-03-24 11:58:04 +08:00
parent 4042ebe3d1
commit e34c15741e
1 changed files with 4 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#ifdef MINGW32
@ -20,11 +21,14 @@ static void die( const char *err) {
/* Function copyright: git */
void xmkstemp( char *template) {
int fd ;
mode_t o_mask ;
o_mask = umask( 0177) ;
fd = mkstemp( template) ;
if( fd < 0)
die( "Unable to create temporary file") ;
umask( o_mask) ;
close( fd) ;
}