Description: Use mkstemp to create temp file
Origin: other
Forwarded: no
--- a/rawlog.c
+++ b/rawlog.c
@@ -158,7 +158,7 @@
 #include "photoproc.h"
 #include "photosyst.h"
 
-#define	BASEPATH	"/var/log/atop/"  
+#define	BASEPATH	"/var/log/atop/"
 
 /*
 ** structure which describes the raw file contents
@@ -566,18 +566,17 @@
 		*/
 		fprintf(stderr, "Decompressing logfile ....\n");
 
-		snprintf(tmpname2, sizeof tmpname2, "/tmp/atopwrk%d", getpid());
-		snprintf(command,  sizeof command, "gunzip -c %s > %s",
-							tmpname1, tmpname2);
-		system (command);
-
-		if ( (rawfd = open(tmpname2, O_RDONLY)) == -1)
+		snprintf(tmpname2, sizeof tmpname2, "/tmp/atopwrkXXXXXX");
+		if ( (rawfd = mkstemp(tmpname2)) == -1)
 		{
 			fprintf(stderr, "%s - ", rawname);
 			perror("open decompressed raw file");
 			cleanstop(7);
 		}
 
+		snprintf(command,  sizeof command, "gunzip -c %s > %s",
+							tmpname1, tmpname2);
+		system (command);
 		unlink(tmpname2);
 	}
 
