pull/574/head
jsteube 8 years ago
commit 7a42c81123

@ -8,6 +8,7 @@
#include "memory.h"
#include "event.h"
#include "debugfile.h"
#include "locking.h"
static void debugfile_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, const u32 plain_len)
{
@ -112,6 +113,13 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx)
return -1;
}
if (lock_file (debugfile_ctx->fp) == -1)
{
event_log_error (hashcat_ctx, "%s: %s", debugfile_ctx->filename, strerror (errno));
return -1;
}
}
else
{

@ -8,6 +8,7 @@
#include "memory.h"
#include "event.h"
#include "dictstat.h"
#include "locking.h"
int sort_by_dictstat (const void *s1, const void *s2)
{
@ -125,6 +126,13 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx)
return -1;
}
if (lock_file (fp) == -1)
{
event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno));
return -1;
}
fwrite (dictstat_ctx->base, sizeof (dictstat_t), dictstat_ctx->cnt, fp);
fclose (fp);

@ -24,6 +24,7 @@
#include "shared.h"
#include "thread.h"
#include "timer.h"
#include "locking.h"
int sort_by_digest_p0p1 (const void *v1, const void *v2, void *v3)
{
@ -144,6 +145,13 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
return -1;
}
if (lock_file (fp) == -1)
{
event_log_error (hashcat_ctx, "%s: %s", new_hashfile, strerror (errno));
return -1;
}
for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
{
if (hashes->salts_shown[salt_pos] == 1) continue;

@ -18,7 +18,11 @@ int lock_file (FILE *fp)
lock.l_type = F_WRLCK;
if (fcntl (fileno (fp), F_SETLKW, &lock)) return -1;
/* Needs this loop because a signal may interrupt a wait for lock */
while (fcntl (fileno (fp), F_SETLKW, &lock))
{
if (errno != EINTR) return -1;
}
return 0;
}

@ -8,6 +8,7 @@
#include "memory.h"
#include "event.h"
#include "logfile.h"
#include "locking.h"
static int logfile_generate_id (void)
{
@ -50,6 +51,8 @@ void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
FILE *fp = fopen (logfile_ctx->logfile, "ab");
lock_file (fp);
va_list ap;
va_start (ap, fmt);

@ -9,6 +9,7 @@
#include "event.h"
#include "shared.h"
#include "loopback.h"
#include "locking.h"
static void loopback_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, const unsigned int plain_len)
{
@ -111,6 +112,13 @@ int loopback_write_open (hashcat_ctx_t *hashcat_ctx)
return -1;
}
if (lock_file (loopback_ctx->fp) == -1)
{
event_log_error (hashcat_ctx, "%s: %s", loopback_ctx->filename, strerror (errno));
return -1;
}
loopback_ctx->unused = true;
return 0;

@ -16,6 +16,7 @@
#include "opencl.h"
#include "shared.h"
#include "outfile.h"
#include "locking.h"
int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u32 *plain_buf, int *out_len)
{
@ -312,6 +313,13 @@ int outfile_write_open (hashcat_ctx_t *hashcat_ctx)
return -1;
}
if (lock_file (outfile_ctx->fp) == -1)
{
event_log_error (hashcat_ctx, "%s: %s", outfile_ctx->filename, strerror (errno));
return -1;
}
return 0;
}

@ -12,6 +12,7 @@
#include "filehandling.h"
#include "outfile.h"
#include "potfile.h"
#include "locking.h"
#if defined (_WIN)
#define __WINDOWS__
@ -318,7 +319,15 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *
tmp_buf[tmp_len] = 0;
if (lock_file (potfile_ctx->fp) == -1)
{
event_log_error (hashcat_ctx, "%s: %s", potfile_ctx->filename, strerror (errno));
}
fprintf (potfile_ctx->fp, "%s" EOL, tmp_buf);
fflush(potfile_ctx->fp);
unlock_file (potfile_ctx->fp);
}
int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)

Loading…
Cancel
Save