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
|
--- applications/lwsrv/lwsrv.c.orig Sat Mar 20 14:38:45 2004
+++ applications/lwsrv/lwsrv.c Sat Mar 20 14:55:51 2004
@@ -1864,7 +1864,7 @@
PFILE *pf;
{
long t;
- int argc, i;
+ int argc, i, fd;
FILE *outfile;
char tname[256],status[256];
char pbuf[256],rhbuf[16],jbuf[1024];
@@ -1930,10 +1930,8 @@
strcat(tname,"/lwsrvXXXXXX");
} else
strcpy(tname,TEMPFILE);
- mktemp(tname);
- if ((outfile = fopen(tname, "w+")) == NULL)
+ if ( ((fd = mkstemp(tname)) == -1 ) || ((outfile = fdopen(fd, "w+")) == NULL) )
perror(tname);
- chmod(tname, 0600);
}
NewStatus(prtp->children <= 0 ? "initializing" : statusprocessing);
@@ -2310,7 +2308,7 @@
PFILE *pf;
{
long t;
- int argc, i;
+ int argc, i, fd;
FILE *outfile;
char tname[256],status[256];
char pbuf[256],rhbuf[16],jbuf[1024];
@@ -2354,16 +2352,15 @@
if (tmpfiledir != NULL) {
strcpy(tname,tmpfiledir);
strcat(tname,"/lwsrvXXXXXX");
+ if ((outfile = fopen(tname, "w+")) == NULL)
+ perror(tname);
+ chmod(tname, 0600);
} else
strcat(tname,TEMPFILE);
- mktemp(tname);
+ if ( ((fd = mkstemp(tname)) == -1 ) || ((outfile = fdopen(fd, "w+")) == NULL) )
+ perror(tname);
}
- if ((outfile = fopen(tname, "w+")) == NULL)
- perror(tname);
-
- chmod(tname, 0600);
-
if (singlefork)
NewStatus("initializing");
|