1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-07-23 06:58:31 +00:00

Merge pull request #4099 from matrix/fix_stdout_race-conditions

Fixed bug in --stdout when multiple computing devices are active
This commit is contained in:
hashcat-bot 2025-07-09 10:14:26 +02:00 committed by GitHub
commit 04b8eb27a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 0 deletions

View File

@ -96,6 +96,7 @@
- Fixed bug in grep out-of-memory workaround on Unit Test
- Fixed bug in input_tokenizer when TOKEN_ATTR_FIXED_LENGTH is used and refactor modules
- Fixed bug in --stdout that caused certain rules to malfunction
- Fixed bug in --stdout when multiple computing devices are active
- Fixed bug in Hardware Monitor: prevent disable if ADL fail
- Fixed race condition in selftest_init on OpenCL with non-blocking write
- Fixed build failed for 10700 optimized with Apple Metal

View File

@ -2210,6 +2210,8 @@ typedef struct outfile_ctx
char *filename;
hc_thread_mutex_t mux_outfile;
} outfile_ctx_t;
typedef struct pot

View File

@ -15,6 +15,7 @@
#include "backend.h"
#include "shared.h"
#include "locking.h"
#include "thread.h"
#include "outfile.h"
u32 outfile_format_parse (const char *format_string)
@ -506,6 +507,8 @@ int outfile_init (hashcat_ctx_t *hashcat_ctx)
outfile_ctx->outfile_json = user_options->outfile_json;
outfile_ctx->is_fifo = hc_path_is_fifo (outfile_ctx->filename);
hc_thread_mutex_init (outfile_ctx->mux_outfile);
return 0;
}
@ -513,6 +516,8 @@ void outfile_destroy (hashcat_ctx_t *hashcat_ctx)
{
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
hc_thread_mutex_delete (outfile_ctx->mux_outfile);
if (outfile_ctx->is_fifo == true && outfile_ctx->fp.pfp != NULL)
{
hc_unlockfile (&outfile_ctx->fp);

View File

@ -12,6 +12,7 @@
#include "mpsp.h"
#include "backend.h"
#include "shared.h"
#include "thread.h"
#include "stdout.h"
static void out_flush (out_t *out)
@ -59,6 +60,10 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
user_options_t *user_options = hashcat_ctx->user_options;
// prevent wrong candidates in output when backend_ctx->backend_devices_active > 1
hc_thread_mutex_lock (outfile_ctx->mux_outfile);
char *filename = outfile_ctx->filename;
out_t out;
@ -69,6 +74,8 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
{
event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno));
hc_thread_mutex_unlock (outfile_ctx->mux_outfile);
return -1;
}
@ -78,6 +85,8 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno));
hc_thread_mutex_unlock (outfile_ctx->mux_outfile);
return -1;
}
}
@ -341,5 +350,7 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
hc_fclose (&out.fp);
}
hc_thread_mutex_unlock (outfile_ctx->mux_outfile);
return rc;
}