1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-27 08:58:10 +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_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_char);
void hc_sleep (const int sec);
void hc_sleep_ms (const int msec);
void hc_sleep (const int sec);
#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);
}
void hc_sleep_ms (const int msec)
{
#if defined (_WIN)
Sleep (msec);
#else
usleep (msec * 1000);
#endif
}
void hc_sleep (const int sec)
{
#if defined (_WIN)
#define sleep(x) Sleep ((x) * 1000)
#endif
Sleep (sec * 1000);
#else
sleep (sec);
#endif
}

View File

@ -27,6 +27,7 @@
#include "loopback.h"
#include "data.h"
#include "status.h"
#include "shared.h"
#include "terminal.h"
extern hc_global_data_t data;
@ -59,16 +60,19 @@ void clear_prompt ()
void *thread_keypress (void *p)
{
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
while (opencl_ctx->devices_status == STATUS_INIT) hc_sleep_ms (100);
hashconfig_t *hashconfig = data.hashconfig;
hashes_t *hashes = data.hashes;
uint quiet = data.quiet;
tty_break();
tty_break ();
while (data.shutdown_outer == 0)
{
int ch = tty_getchar();
int ch = tty_getchar ();
if (ch == -1) break;
@ -164,7 +168,7 @@ void *thread_keypress (void *p)
hc_thread_mutex_unlock (mux_display);
}
tty_fix();
tty_fix ();
return (p);
}