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
|
$NetBSD: patch-ai,v 1.2 2005/12/05 20:50:58 rillig Exp $
--- src/siggen.c.orig 1994-07-25 08:24:12.000000000 -0700
+++ src/siggen.c
@@ -52,7 +52,6 @@
extern int optind;
int debuglevel = 0;
-char *mktemp();
int (*pf_signatures [NUM_SIGS]) () = {
SIG0FUNC,
@@ -164,6 +163,7 @@ main(argc, argv)
}
if (readstdin) {
+ int fdout;
FILE *fpout;
/* generate temporary file name */
if ((tmpfilename = (char *) malloc(L_tmpnam + MAXPATHLEN)) == NULL) {
@@ -172,32 +172,26 @@ main(argc, argv)
};
(void) strcpy(tmpfilename, "/tmp/twzXXXXXX");
- if ((char *) mktemp(tmpfilename) == NULL) {
- perror("siggen: mktemp()");
+ fdout = mkstemp(tmpfilename);
+ if (fdout == -1) {
+ perror("siggen: mkstemp()");
exit(1);
}
+ unlink(tmpfilename);
/* output */
- if (!(fpout = fopen(tmpfilename, "w"))) {
- char err[1024];
- sprintf(err, "main: fopen(%s)", tmpfilename);
- perror(err);
+ if (!(fpout = fdopen(fdout, "w"))) {
+ perror("siggen: fdopen()");
exit(1);
}
/* copy */
while ((c = getc(stdin)) != EOF)
putc(c, fpout);
- fclose(fpout);
- if ((fd = open(tmpfilename, O_RDONLY)) < 0) {
- perror("siggen: open");
- exit(1);
- }
- if (siggen(fd) < 0)
+ rewind(fpout);
+ if (siggen(fdout) < 0)
errors++;
- if (fd)
- close(fd);
- unlink(tmpfilename);
+ fclose(fpout);
}
if (errors)
|