summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2006-03-10 00:48:57 +0000
committerJoris Vink <joris@cvs.openbsd.org>2006-03-10 00:48:57 +0000
commit821d9995abbf1471659a6dc5e4609247b78a52b0 (patch)
tree9f851d79e42efe29cd2eadd27e9dd5162c44a597
parent5f437aed7f0d5612e2854ddae179f910d35f9a35 (diff)
make sure cvs_worklist_clean() is safe, since we are
calling it from inside a signal handler. from deraadt@, ok niallo@
-rw-r--r--usr.bin/cvs/worklist.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.bin/cvs/worklist.c b/usr.bin/cvs/worklist.c
index 2c6ae0bd0e5..f7f887d4358 100644
--- a/usr.bin/cvs/worklist.c
+++ b/usr.bin/cvs/worklist.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: worklist.c,v 1.1 2006/03/08 20:18:41 joris Exp $ */
+/* $OpenBSD: worklist.c,v 1.2 2006/03/10 00:48:56 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -61,28 +61,31 @@ void
cvs_worklist_run(struct cvs_wklhead *list, void (*cb)(struct cvs_worklist *))
{
sigset_t old, new;
+ struct cvs_worklist *wkl;
sigfillset(&new);
sigprocmask(SIG_BLOCK, &new, &old);
cvs_worklist_clean(list, cb);
+ while ((wkl = SLIST_FIRST(list)) != NULL) {
+ SLIST_REMOVE_HEAD(list, wkl_list);
+ xfree(wkl);
+ }
+
sigprocmask(SIG_SETMASK, &old, NULL);
}
/*
- * clean the worklist by passing the elements to the specified callback
+ * pass elements to the specified callback, which has to be signal safe.
*/
void
cvs_worklist_clean(struct cvs_wklhead *list, void (*cb)(struct cvs_worklist *))
{
struct cvs_worklist *wkl;
- while ((wkl = SLIST_FIRST(list)) != NULL) {
- SLIST_REMOVE_HEAD(list, wkl_list);
+ while ((wkl = SLIST_FIRST(list)) != NULL)
cb(wkl);
- xfree(wkl);
- }
}
void