-/* $OpenBSD: patch.c,v 1.4 1996/07/01 20:40:09 deraadt Exp $ */
+/* $OpenBSD: patch.c,v 1.5 1996/09/15 19:19:54 millert Exp $ */
/* patch - a program to apply diffs to original files
*
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: patch.c,v 1.4 1996/07/01 20:40:09 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: patch.c,v 1.5 1996/09/15 19:19:54 millert Exp $";
#endif /* not lint */
#include "INTERN.h"
init_output(name)
char *name;
{
- ofp = fopen(name, "w");
- if (ofp == Nullfp)
+ int ofd;
+
+ if ((ofd = open(name, O_CREAT|O_EXCL|O_WRONLY, 0600)) < 0 ||
+ (ofp = fdopen(ofd, "w")) == Nullfp)
pfatal2("can't create %s", name);
}
init_reject(name)
char *name;
{
- rejfp = fopen(name, "w");
- if (rejfp == Nullfp)
+ int rejfd;
+
+ if ((rejfd = open(name, O_CREAT|O_EXCL|O_WRONLY, 0600)) < 0 ||
+ (rejfp = fdopen(rejfd, "w")) == Nullfp)
pfatal2("can't create %s", name);
}
-/* $OpenBSD: pch.c,v 1.4 1996/07/01 20:40:10 deraadt Exp $ */
+/* $OpenBSD: pch.c,v 1.5 1996/09/15 19:19:52 millert Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: pch.c,v 1.4 1996/07/01 20:40:10 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: pch.c,v 1.5 1996/09/15 19:19:52 millert Exp $";
#endif /* not lint */
#include "EXTERN.h"
char *filename;
{
if (filename == Nullch || !*filename || strEQ(filename, "-")) {
- pfp = fopen(TMPPATNAME, "w");
- if (pfp == Nullfp)
+ int pfd;
+
+ if ((pfd = open(TMPPATNAME, O_CREAT|O_EXCL|O_WRONLY, 0600)) < 0 ||
+ (pfp = fdopen(pfd, "w")) == Nullfp)
pfatal2("can't create %s", TMPPATNAME);
while (fgets(buf, sizeof buf, stdin) != Nullch)
fputs(buf, pfp);