diff options
author | Jeffrey Walton <noloader@gmail.com> | 2020-02-17 14:15:02 -0500 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2020-02-17 14:15:02 -0500 |
commit | 6fa3e38e5c26820396d11a5a155fc83790d17c72 (patch) | |
tree | d1aef601107380e718b1efffa34eb90cea34b130 /cpu.cpp | |
parent | a76c29a11e9029132f537f6853a9daa846f54f03 (diff) | |
download | cryptopp-git-6fa3e38e5c26820396d11a5a155fc83790d17c72.tar.gz |
Restore SIGILL handler if sigprocmask fails
We've never encountered this case, but better safe then sorry.
Diffstat (limited to 'cpu.cpp')
-rw-r--r-- | cpu.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -72,9 +72,8 @@ extern "C" { extern "C"
{
static jmp_buf s_jmpNoCPUID;
- static void SigIllHandlerCPUID(int unused)
+ static void SigIllHandler(int)
{
- CRYPTOPP_UNUSED(unused);
longjmp(s_jmpNoCPUID, 1);
}
}
@@ -358,14 +357,17 @@ bool CpuId(word32 func, word32 subfunc, word32 output[4]) // http://github.com/weidai11/cryptopp/issues/24 and http://stackoverflow.com/q/7721854
volatile bool result = true;
- volatile SigHandler oldHandler = signal(SIGILL, SigIllHandlerCPUID);
+ volatile SigHandler oldHandler = signal(SIGILL, SigIllHandler);
if (oldHandler == SIG_ERR)
return false;
# ifndef __MINGW32__
volatile sigset_t oldMask;
if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask) != 0)
+ {
+ signal(SIGILL, oldHandler);
return false;
+ }
# endif
if (setjmp(s_jmpNoCPUID))
|