summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoris <joris@openbsd.org>2006-03-30 23:19:20 +0000
committerjoris <joris@openbsd.org>2006-03-30 23:19:20 +0000
commit8933887bcece09eab4e428c493dfbc26803b53cd (patch)
tree28d1bf8d3e8d42529af0f5348a901ac49c7938fd
parenthmm, let's not use fatal() when we cannot find a branch instead return NULL (diff)
downloadwireguard-openbsd-8933887bcece09eab4e428c493dfbc26803b53cd.tar.xz
wireguard-openbsd-8933887bcece09eab4e428c493dfbc26803b53cd.zip
add temporary files to the worklist before creating them, this prevents
a race when the user would interrupt the program when it was returning from cvs_buf_write_stmp() and leave the temporary files behind.
-rw-r--r--usr.bin/rcs/ci.c8
-rw-r--r--usr.bin/rcs/rcsdiff.c14
2 files changed, 14 insertions, 8 deletions
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c
index 30e39a9e42c..dcfa42814eb 100644
--- a/usr.bin/rcs/ci.c
+++ b/usr.bin/rcs/ci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ci.c,v 1.131 2006/03/28 12:48:51 xsa Exp $ */
+/* $OpenBSD: ci.c,v 1.132 2006/03/30 23:19:20 joris Exp $ */
/*
* Copyright (c) 2005, 2006 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
@@ -327,17 +327,19 @@ checkin_diff_file(struct checkin_params *pb)
strlcpy(path1, rcs_tmpdir, sizeof(path1));
strlcat(path1, "/diff1.XXXXXXXXXX", sizeof(path1));
- cvs_buf_write_stmp(b1, path1, 0600);
cvs_worklist_add(path1, &rcs_temp_files);
+ cvs_buf_write_stmp(b1, path1, 0600);
+
cvs_buf_free(b1);
b1 = NULL;
strlcpy(path2, rcs_tmpdir, sizeof(path2));
strlcat(path2, "/diff2.XXXXXXXXXX", sizeof(path2));
- cvs_buf_write_stmp(b2, path2, 0600);
cvs_worklist_add(path2, &rcs_temp_files);
+ cvs_buf_write_stmp(b2, path2, 0600);
+
cvs_buf_free(b2);
b2 = NULL;
diff --git a/usr.bin/rcs/rcsdiff.c b/usr.bin/rcs/rcsdiff.c
index 24bad19731b..c791d6b1059 100644
--- a/usr.bin/rcs/rcsdiff.c
+++ b/usr.bin/rcs/rcsdiff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsdiff.c,v 1.41 2006/03/24 05:14:48 ray Exp $ */
+/* $OpenBSD: rcsdiff.c,v 1.42 2006/03/30 23:19:20 joris Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -209,9 +209,10 @@ rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename)
strlcpy(path1, rcs_tmpdir, sizeof(path1));
strlcat(path1, "/diff1.XXXXXXXXXX", sizeof(path1));
- cvs_buf_write_stmp(b1, path1, 0600);
cvs_worklist_add(path1, &rcs_temp_files);
+ cvs_buf_write_stmp(b1, path1, 0600);
+
cvs_buf_free(b1);
b1 = NULL;
@@ -220,9 +221,10 @@ rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename)
strlcpy(path2, rcs_tmpdir, sizeof(path2));
strlcat(path2, "/diff2.XXXXXXXXXX", sizeof(path2));
- cvs_buf_write_stmp(b2, path2, 0600);
cvs_worklist_add(path2, &rcs_temp_files);
+ cvs_buf_write_stmp(b2, path2, 0600);
+
cvs_buf_free(b2);
b2 = NULL;
@@ -288,9 +290,10 @@ rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2)
strlcpy(path1, rcs_tmpdir, sizeof(path1));
strlcat(path1, "/diff1.XXXXXXXXXX", sizeof(path1));
- cvs_buf_write_stmp(b1, path1, 0600);
cvs_worklist_add(path1, &rcs_temp_files);
+ cvs_buf_write_stmp(b1, path1, 0600);
+
cvs_buf_free(b1);
b1 = NULL;
@@ -299,9 +302,10 @@ rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2)
strlcpy(path2, rcs_tmpdir, sizeof(path2));
strlcat(path2, "/diff2.XXXXXXXXXX", sizeof(path2));
- cvs_buf_write_stmp(b2, path2, 0600);
cvs_worklist_add(path2, &rcs_temp_files);
+ cvs_buf_write_stmp(b2, path2, 0600);
+
cvs_buf_free(b2);
b2 = NULL;