Fixing race condition involved with SIGINT after signal handler runs.

pull/3633/head
Mohamed Tawous 1 year ago
parent 313bc83804
commit 5995e009aa

@ -54,9 +54,6 @@
#include "brain.h"
#endif
// hashcat_ctx stored globally for signal handling
hashcat_ctx_t *hc_ctx;
// inner2_loop iterates through wordlists, then calls kernel execution
static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
@ -1095,8 +1092,7 @@ int hashcat_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct h
hashcat_ctx->user_options_extra = (user_options_extra_t *) hcmalloc (sizeof (user_options_extra_t));
hashcat_ctx->user_options = (user_options_t *) hcmalloc (sizeof (user_options_t));
hashcat_ctx->wl_data = (wl_data_t *) hcmalloc (sizeof (wl_data_t));
hc_ctx = hashcat_ctx;
return 0;
}

@ -28,6 +28,9 @@
int _dowildcard = -1;
#endif
// hashcat_ctx stored globally for signal handling
hashcat_ctx_t *hc_ctx;
static void main_log_clear_line (MAYBE_UNUSED const size_t prev_len, MAYBE_UNUSED FILE *fp)
{
if (!is_stdout_terminal ()) return;
@ -1284,6 +1287,10 @@ int main (int argc, char **argv)
return 0;
}
// Initializing the hashcat ctx global pointer for the signal handler
hc_ctx = hashcat_ctx;
// init a hashcat session; this initializes backend devices, hwmon, etc
welcome_screen (hashcat_ctx, VERSION_TAG);

@ -92,16 +92,24 @@ void hc_signal (BOOL WINAPI (callback) (DWORD))
void sigHandler_default (int sig)
{
myabort (hc_ctx);
if (hc_ctx)
{
hc_ctx = NULL;
myabort (hc_ctx);
}
signal (sig, NULL);
// signal (sig, NULL);
}
void sigHandler_benchmark (int sig)
{
myquit (hc_ctx);
if (hc_ctx)
{
hc_ctx = NULL;
myquit (hc_ctx);
}
signal (sig, NULL);
// signal (sig, NULL);
}
void hc_signal (void (callback) (int))

Loading…
Cancel
Save