aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcryptobox/cryptobox.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-15 18:18:11 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-15 18:18:11 +0100
commit01a94d2edbdcc64b25ab94709b302725a1a6d58a (patch)
tree6d8a36d037a72168654f815bdfc6a7873b38fad8 /src/libcryptobox/cryptobox.c
parentd3a00149e41f959408ac487f8428204693cdd79a (diff)
downloadrspamd-01a94d2edbdcc64b25ab94709b302725a1a6d58a.tar.gz
rspamd-01a94d2edbdcc64b25ab94709b302725a1a6d58a.zip
Try to handle SIGILL properly.
Issue: #399
Diffstat (limited to 'src/libcryptobox/cryptobox.c')
-rw-r--r--src/libcryptobox/cryptobox.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libcryptobox/cryptobox.c b/src/libcryptobox/cryptobox.c
index 2ecc707a7..5dffaff4e 100644
--- a/src/libcryptobox/cryptobox.c
+++ b/src/libcryptobox/cryptobox.c
@@ -41,6 +41,7 @@
#endif
#include <signal.h>
+#include <setjmp.h>
unsigned long cpu_config = 0;
@@ -92,11 +93,13 @@ rspamd_cryptobox_cpuid (gint cpu[4], gint info)
}
static sig_atomic_t ok = 0;
+static jmp_buf j;
static void
rspamd_cryptobox_ill_handler (int signo)
{
ok = 0;
+ longjmp (j, -1);
}
static gboolean
@@ -108,6 +111,12 @@ rspamd_cryptobox_test_instr (gint instr)
ok = 1;
old_handler = signal (SIGILL, rspamd_cryptobox_ill_handler);
+ if (setjmp (j) != 0) {
+ signal (SIGILL, old_handler);
+
+ return FALSE;
+ }
+
switch (instr) {
#ifdef HAVE_SSE2
case CPUID_SSE2:
@@ -146,6 +155,7 @@ rspamd_cryptobox_test_instr (gint instr)
signal (SIGILL, old_handler);
#endif
+ /* We actually never return here if SIGILL has been caught */
return ok == 1;
}