summaryrefslogtreecommitdiff
blob: c672a27554da07594df0fb80b0ddf8c8c97c1d73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Missed hunk noticed https://bugzilla.redhat.com/show_bug.cgi?id=505257#c1 is recreated.

http://bugs.gentoo.org/show_bug.cgi?id=264575

=== modified file 'u_print.c'
--- u_print.c	2010-01-14 19:50:08 +0000
+++ u_print.c	2010-01-14 19:54:14 +0000
@@ -202,14 +202,22 @@
     char	    tmp_fig_file[PATH_MAX];
     char	   *outfile, *name, *real_lang;
     char	   *suf;
+    int     fd;
 
     /* if file exists, ask if ok */
     if (!ok_to_write(file, "EXPORT"))
 	return (1);
 
-    sprintf(tmp_fig_file, "%s/%s%06d", TMPDIR, "xfig-fig", getpid());
+    snprintf(tmp_fig_file, sizeof(tmp_fig_file), "%s/xfig-fig.XXXXXX", TMPDIR);
     /* write the fig objects to a temporary file */
     warnexist = False;
+
+    if ((fd = mkstemp(tmp_fig_file)) == -1) {
+       file_msg("Can't open temp file %s: %s\n", tmp_fig_file, strerror(errno));
+       return;
+    }
+    close(fd);
+
     init_write_tmpfile();
     if (write_file(tmp_fig_file, False)) {
       end_write_tmpfile();