Browse Source

Try to handle SIGILL properly.

Issue: #399
tags/1.0.6
Vsevolod Stakhov 8 years ago
parent
commit
01a94d2edb
1 changed files with 10 additions and 0 deletions
  1. 10
    0
      src/libcryptobox/cryptobox.c

+ 10
- 0
src/libcryptobox/cryptobox.c View File

@@ -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;
}


Loading…
Cancel
Save