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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
--- util/makedefs.c.orig 2015-11-09 11:13:10 UTC
+++ util/makedefs.c
@@ -135,6 +135,7 @@
/*-end of vision defs-*/
static char filename[600];
+static char tempfilename[600]; /* grep.tmp.<pid> */
#ifdef FILE_PREFIX
/* if defined, a first argument not starting with - is
@@ -261,6 +262,12 @@
return 1;
}
+ if (snprintf(tempfilename, sizeof(tempfilename), "%s.%d", "grep.tmp", getpid()) >= sizeof(tempfilename)) {
+ Fprintf(stderr, "Cannot create temporary filename.");
+ (void) fflush(stderr);
+ return 1;
+ }
+
#ifdef FILE_PREFIX
if (argc >= 2 && argv[1][0] != '-') {
file_prefix = argv[1];
@@ -949,9 +956,9 @@
}
Fprintf(ofp, "%s", Dont_Edit_Data);
- tfp = getfp(DATA_TEMPLATE, "grep.tmp", WRTMODE);
+ tfp = getfp(DATA_TEMPLATE, tempfilename, WRTMODE);
grep0(ifp, tfp);
- ifp = getfp(DATA_TEMPLATE, "grep.tmp", RDTMODE);
+ ifp = getfp(DATA_TEMPLATE, tempfilename, RDTMODE);
while ((line = fgetline(ifp)) != 0) {
if (line[0] != '#' && line[0] != '\n')
@@ -961,7 +968,7 @@
Fclose(ifp);
Fclose(ofp);
- delete_file(DATA_TEMPLATE, "grep.tmp");
+ delete_file(DATA_TEMPLATE, tempfilename);
return;
}
@@ -1955,9 +1962,9 @@
}
Fprintf(ofp, "%s", Dont_Edit_Data);
- tfp = getfp(DATA_TEMPLATE, "grep.tmp", WRTMODE);
+ tfp = getfp(DATA_TEMPLATE, tempfilename, WRTMODE);
grep0(ifp, tfp);
- ifp = getfp(DATA_TEMPLATE, "grep.tmp", RDTMODE);
+ ifp = getfp(DATA_TEMPLATE, tempfilename, RDTMODE);
while ((line = fgetline(ifp)) != 0) {
SpinCursor(3);
@@ -1973,7 +1980,7 @@
Fclose(ifp);
Fclose(ofp);
- delete_file(DATA_TEMPLATE, "grep.tmp");
+ delete_file(DATA_TEMPLATE, tempfilename);
return;
}
|