summaryrefslogtreecommitdiff
path: root/usr.bin/sort
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-04-01 22:43:17 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-04-01 22:43:17 +0000
commit92b0a0a1a93c44340de34bdac39c37e74ca21b9b (patch)
tree0b2b039ce1c8e994a372e7d21e83075a45c8b8f1 /usr.bin/sort
parent9125df0abb00d8140cbc1c6f75e4bd1c3259fc70 (diff)
Block signals during tmp_files insertion, so that the signal handler
cannot encounter an incoherent list. It was an absolutely tiny signal race. ok millert
Diffstat (limited to 'usr.bin/sort')
-rw-r--r--usr.bin/sort/file.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.bin/sort/file.c b/usr.bin/sort/file.c
index b97d5a76ffd..ee3fc3c87c7 100644
--- a/usr.bin/sort/file.c
+++ b/usr.bin/sort/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.13 2015/04/01 22:24:02 millert Exp $ */
+/* $OpenBSD: file.c,v 1.14 2015/04/01 22:43:16 deraadt Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -36,6 +36,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <signal.h>
#include <string.h>
#include <unistd.h>
#include <wchar.h>
@@ -116,10 +117,15 @@ void
tmp_file_atexit(const char *tmp_file)
{
struct CLEANABLE_FILE *item;
+ sigset_t mask, oldmask;
item = sort_malloc(sizeof(struct CLEANABLE_FILE));
item->fn = sort_strdup(tmp_file);
+
+ sigfillset(&mask);
+ sigprocmask(SIG_BLOCK, &mask, &oldmask);
LIST_INSERT_HEAD(&tmp_files, item, files);
+ sigprocmask(SIG_SETMASK, &oldmask, NULL);
}
/*