File: use_mkstemp_instead_of_tmpnam.patch

package info (click to toggle)
staden 2.0.0%2Bb11-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,584 kB
  • sloc: ansic: 240,605; tcl: 65,360; cpp: 12,854; makefile: 11,203; sh: 3,023; fortran: 2,033; perl: 63; awk: 46
file content (45 lines) | stat: -rw-r--r-- 1,210 bytes parent folder | download
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
33
34
35
36
37
38
39
40
41
42
43
44
45
Description: Replace tmpnam by mkostemp
Bug-Debian: https://bugs.debian.org/825461
Author: Andreas Tille <tille@debian.org>
Last-Update: 2016-05-27

--- staden.orig/tk_utils/capture.c
+++ staden/tk_utils/capture.c
@@ -5,6 +5,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <stdlib.h>
 
 #include "os.h"
 #include "capture.h"
@@ -17,7 +18,7 @@
     static int fd = 0;
     char *buf;
     struct stat statbuf;
-    char *tmpfile;
+    char template[] = "/tmp/tcl_capture.XXXXXX";
     int result;
 
     if (argc != 2 && argc != 3) {
@@ -28,8 +29,7 @@
 
     /* File descriptor mangling */
     if (!fd) {
-	tmpfile = tmpnam(NULL);
-	fd = open(tmpfile, O_RDWR|O_CREAT|O_TRUNC, 0666);
+	fd = mkostemp(template, 0666);
     } else {
 	lseek(fd, 0, SEEK_SET);
     }
--- staden.orig/tk_utils/Makefile
+++ staden/tk_utils/Makefile
@@ -13,7 +13,7 @@
 INCLUDES_E += $(MISC_INC) $(TKUTILS_INC) $(IOLIB_INC) $(TK_INC) \
 	      $(SEQUTILS_INC) $(BIOLIMS_INC) $(PNG_INC)
 
-CFLAGS += $(SHLIB_CFLAGS) $(TK_UTILS_DLL)
+CFLAGS += $(SHLIB_CFLAGS) $(TK_UTILS_DLL) -D_GNU_SOURCE
 
 #DEFINES += -DCHECK_LICENCE -DTCL_LOCAL_APPINIT=Stash_AppInit
 #DEFINES += -DTCL_LOCAL_APPINIT=Stash_AppInit