diff options
author | 2015-04-01 22:43:16 +0000 | |
---|---|---|
committer | 2015-04-01 22:43:16 +0000 | |
commit | df61954f62670aa6a05f97db17cc559677322757 (patch) | |
tree | 09b7b161f6efc114e05ff2f858a2d74607c54837 | |
parent | Use reallocarray instead of malloc. (diff) | |
download | wireguard-openbsd-df61954f62670aa6a05f97db17cc559677322757.tar.xz wireguard-openbsd-df61954f62670aa6a05f97db17cc559677322757.zip |
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
-rw-r--r-- | usr.bin/sort/file.c | 8 |
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); } /* |