blob: 24632fe5221c73c4cb4b5f729bcfa27b1655f4e7 (
plain) (
blame)
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
|
--- ispell.c-orig Thu May 24 14:52:00 2001
+++ ispell.c Thu May 24 15:00:06 2001
@@ -802,6 +802,7 @@
{
struct stat statbuf;
char * cp;
+ int fd;
currentfile = filename;
@@ -835,15 +836,20 @@
(void) fstat (fileno (infile), &statbuf);
(void) strcpy (tempfile, TEMPNAME);
- if (mktemp (tempfile) == NULL || tempfile[0] == '\0'
- || (outfile = fopen (tempfile, "w")) == NULL)
- {
- (void) fprintf (stderr, CANT_CREATE,
- (tempfile == NULL || tempfile[0] == '\0')
- ? "temporary file" : tempfile);
- (void) sleep ((unsigned) 2);
- return;
- }
+
+ if ((fd = mkstemp(tempfile)) == -1) {
+ fprintf(stderr, "Error: Can't create (mkstemp) temporary file\n");
+ sleep(2);
+ return;
+ }
+ if ((outfile = fdopen(fd, "w")) == NULL) {
+ unlink(tempfile);
+ close(fd);
+ fprintf(stderr, "Error: Can't open (fdopen) temporary file\n");
+ sleep(2);
+ return;
+ }
+ /* Is this necessary ? */
(void) chmod (tempfile, statbuf.st_mode);
quit = 0;
|