1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-07-03 21:32:35 +00:00

Fix race-condition in thread_keypress()

This commit is contained in:
jsteube 2016-09-20 12:32:39 +02:00
parent 57195b475a
commit 4cde17aea7
3 changed files with 21 additions and 7 deletions

View File

@ -18,6 +18,7 @@ u64 mydivc64 (const u64 dividend, const u64 divisor);
void naive_replace (char *s, const u8 key_char, const u8 replace_char); void naive_replace (char *s, const u8 key_char, const u8 replace_char);
void naive_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_char); void naive_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_char);
void hc_sleep_ms (const int msec);
void hc_sleep (const int sec); void hc_sleep (const int sec);
#endif // _SHARED_H #endif // _SHARED_H

View File

@ -74,11 +74,20 @@ void naive_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_cha
strncpy (s, s_escaped, s_max - 1); strncpy (s, s_escaped, s_max - 1);
} }
void hc_sleep_ms (const int msec)
{
#if defined (_WIN)
Sleep (msec);
#else
usleep (msec * 1000);
#endif
}
void hc_sleep (const int sec) void hc_sleep (const int sec)
{ {
#if defined (_WIN) #if defined (_WIN)
#define sleep(x) Sleep ((x) * 1000) Sleep (sec * 1000);
#endif #else
sleep (sec); sleep (sec);
#endif
} }

View File

@ -27,6 +27,7 @@
#include "loopback.h" #include "loopback.h"
#include "data.h" #include "data.h"
#include "status.h" #include "status.h"
#include "shared.h"
#include "terminal.h" #include "terminal.h"
extern hc_global_data_t data; extern hc_global_data_t data;
@ -59,6 +60,9 @@ void clear_prompt ()
void *thread_keypress (void *p) void *thread_keypress (void *p)
{ {
opencl_ctx_t *opencl_ctx = data.opencl_ctx; opencl_ctx_t *opencl_ctx = data.opencl_ctx;
while (opencl_ctx->devices_status == STATUS_INIT) hc_sleep_ms (100);
hashconfig_t *hashconfig = data.hashconfig; hashconfig_t *hashconfig = data.hashconfig;
hashes_t *hashes = data.hashes; hashes_t *hashes = data.hashes;