mirror of
https://github.com/hashcat/hashcat.git
synced 2025-07-04 22:02:36 +00:00
Fix race-condition in thread_keypress()
This commit is contained in:
parent
57195b475a
commit
4cde17aea7
@ -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
|
||||||
|
15
src/shared.c
15
src/shared.c
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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,16 +60,19 @@ 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;
|
||||||
|
|
||||||
uint quiet = data.quiet;
|
uint quiet = data.quiet;
|
||||||
|
|
||||||
tty_break();
|
tty_break ();
|
||||||
|
|
||||||
while (data.shutdown_outer == 0)
|
while (data.shutdown_outer == 0)
|
||||||
{
|
{
|
||||||
int ch = tty_getchar();
|
int ch = tty_getchar ();
|
||||||
|
|
||||||
if (ch == -1) break;
|
if (ch == -1) break;
|
||||||
|
|
||||||
@ -164,7 +168,7 @@ void *thread_keypress (void *p)
|
|||||||
hc_thread_mutex_unlock (mux_display);
|
hc_thread_mutex_unlock (mux_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
tty_fix();
|
tty_fix ();
|
||||||
|
|
||||||
return (p);
|
return (p);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user