summaryrefslogtreecommitdiffstats
path: root/usr.bin/patch/patch.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>1996-09-24 02:58:52 +0000
committermillert <millert@openbsd.org>1996-09-24 02:58:52 +0000
commit7ffd4e56ed7ab019d24a59177e1efcb640754f95 (patch)
tree1962f5307dc60de45dd580c4a4b04df56f608112 /usr.bin/patch/patch.c
parentno mknod in chroot (diff)
downloadwireguard-openbsd-7ffd4e56ed7ab019d24a59177e1efcb640754f95.tar.xz
wireguard-openbsd-7ffd4e56ed7ab019d24a59177e1efcb640754f95.zip
Use mkstemp(). Since temp files get re-used we use mkstemp() to make
us a "place holder" (and discard the fd) to protect from DOS attacks and then just re-use that.
Diffstat (limited to 'usr.bin/patch/patch.c')
-rw-r--r--usr.bin/patch/patch.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index 9ad408495da..41884781e03 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: patch.c,v 1.6 1996/09/23 10:54:21 deraadt Exp $ */
+/* $OpenBSD: patch.c,v 1.7 1996/09/24 02:58:52 millert Exp $ */
/* patch - a program to apply diffs to original files
*
@@ -9,7 +9,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: patch.c,v 1.6 1996/09/23 10:54:21 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: patch.c,v 1.7 1996/09/24 02:58:52 millert Exp $";
#endif /* not lint */
#include "INTERN.h"
@@ -81,22 +81,30 @@ char **argv;
TMPOUTNAME = (char *) malloc (tmpname_len);
strcpy (TMPOUTNAME, tmpdir);
strcat (TMPOUTNAME, "/patchoXXXXXX");
- Mktemp(TMPOUTNAME);
+ if ((i = Mkstemp(TMPOUTNAME)) < 0)
+ pfatal2("can't create %s", TMPOUTNAME);
+ Close(i);
TMPINNAME = (char *) malloc (tmpname_len);
strcpy (TMPINNAME, tmpdir);
strcat (TMPINNAME, "/patchiXXXXXX");
- Mktemp(TMPINNAME);
+ if ((i = Mkstemp(TMPINNAME)) < 0)
+ pfatal2("can't create %s", TMPINNAME);
+ Close(i);
TMPREJNAME = (char *) malloc (tmpname_len);
strcpy (TMPREJNAME, tmpdir);
strcat (TMPREJNAME, "/patchrXXXXXX");
- Mktemp(TMPREJNAME);
+ if ((i = Mkstemp(TMPREJNAME)) < 0)
+ pfatal2("can't create %s", TMPREJNAME);
+ Close(i);
TMPPATNAME = (char *) malloc (tmpname_len);
strcpy (TMPPATNAME, tmpdir);
strcat (TMPPATNAME, "/patchpXXXXXX");
- Mktemp(TMPPATNAME);
+ if ((i = Mkstemp(TMPPATNAME)) < 0)
+ pfatal2("can't create %s", TMPPATNAME);
+ Close(i);
}
{