$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)