mirror of
https://github.com/hashcat/hashcat.git
synced 2025-02-16 17:42:04 +00:00
Remove union from HCFILE, using std file ops in ocl_check_dri, remove debug comments
This commit is contained in:
parent
c2e634c426
commit
5d3ed3e754
@ -993,15 +993,12 @@ typedef struct link_speed
|
||||
|
||||
typedef struct hc_fp
|
||||
{
|
||||
union
|
||||
{
|
||||
FILE *fp;
|
||||
gzFile gfp;
|
||||
} f;
|
||||
FILE *pfp;
|
||||
gzFile gfp;
|
||||
|
||||
bool is_gzip;
|
||||
bool is_gzip;
|
||||
char *mode;
|
||||
const char *path;
|
||||
char *mode;
|
||||
} HCFILE;
|
||||
|
||||
#include "ext_nvrtc.h"
|
||||
|
@ -137,25 +137,20 @@ static int ocl_check_dri (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
// Now we need to check if this an AMD vendor, because this is when the problems start
|
||||
|
||||
HCFILE fp_drm;
|
||||
// FILE *fd_drm = fopen (drm_card0_vendor_path, "rb");
|
||||
FILE *fd_drm = fopen (drm_card0_vendor_path, "rb");
|
||||
|
||||
if (hc_fopen (&fp_drm, drm_card0_vendor_path, "rb") == false) return 0;
|
||||
// if (fd_drm == NULL) return 0;
|
||||
if (fd_drm == NULL) return 0;
|
||||
|
||||
u32 vendor = 0;
|
||||
|
||||
// if (fscanf (fd_drm, "0x%x", &vendor) != 1)
|
||||
if (hc_fscanf (&fp_drm, "0x%x", &vendor) != 1)
|
||||
if (fscanf (fd_drm, "0x%x", &vendor) != 1)
|
||||
{
|
||||
// fclose (fd_drm);
|
||||
hc_fclose (&fp_drm);
|
||||
fclose (fd_drm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// fclose (fd_drm);
|
||||
hc_fclose (&fp_drm);
|
||||
fclose (fd_drm);
|
||||
|
||||
if (vendor != 4098) return 0;
|
||||
|
||||
@ -173,11 +168,9 @@ static int ocl_check_dri (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
// Now do the real check
|
||||
|
||||
HCFILE fp_dri;
|
||||
// FILE *fd_dri = fopen (dri_card0_path, "rb");
|
||||
FILE *fd_dri = fopen (dri_card0_path, "rb");
|
||||
|
||||
if (hc_fopen (&fp_dri, dri_card0_path, "rb") == false)
|
||||
// if (fd_dri == NULL)
|
||||
if (fd_dri == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Cannot access %s: %m.", dri_card0_path);
|
||||
|
||||
@ -189,8 +182,7 @@ static int ocl_check_dri (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// fclose (fd_dri);
|
||||
hc_fclose (&fp_drm);
|
||||
fclose (fd_dri);
|
||||
|
||||
#endif // __linux__
|
||||
|
||||
@ -448,17 +440,14 @@ static bool opencl_test_instruction (hashcat_ctx_t *hashcat_ctx, cl_context cont
|
||||
|
||||
static bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_file, size_t *kernel_lengths, char **kernel_sources, const bool force_recompile)
|
||||
{
|
||||
// FILE *fp = fopen (kernel_file, "rb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp != NULL)
|
||||
if (hc_fopen (&fp, kernel_file, "rb") != false)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat (kernel_file, &st))
|
||||
{
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return false;
|
||||
@ -470,7 +459,6 @@ static bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_f
|
||||
|
||||
size_t num_read = hc_fread (buf, sizeof (char), st.st_size, &fp);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
if (num_read != (size_t) st.st_size)
|
||||
@ -515,10 +503,8 @@ static bool write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file,
|
||||
{
|
||||
if (binary_size > 0)
|
||||
{
|
||||
// FILE *fp = fopen (kernel_file, "wb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL)
|
||||
if (hc_fopen (&fp, kernel_file, "wb") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", kernel_file, strerror (errno));
|
||||
@ -528,10 +514,8 @@ static bool write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file,
|
||||
|
||||
fp.is_gzip = false;
|
||||
|
||||
// if (lock_file (fp) == -1)
|
||||
if (lock_file (fp.f.fp) == -1)
|
||||
if (lock_file (fp.pfp) == -1)
|
||||
{
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
event_log_error (hashcat_ctx, "%s: %s", kernel_file, strerror (errno));
|
||||
@ -541,10 +525,8 @@ static bool write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file,
|
||||
|
||||
hc_fwrite (binary, sizeof (char), binary_size, &fp);
|
||||
|
||||
// fflush (fp);
|
||||
hc_fflush (&fp);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
}
|
||||
|
||||
|
31
src/brain.c
31
src/brain.c
@ -539,21 +539,17 @@ u64 brain_compute_attack_wordlist (const char *filename)
|
||||
|
||||
char buf[FBUFSZ];
|
||||
|
||||
// FILE *fd = fopen (filename, "rb");
|
||||
HCFILE fp;
|
||||
|
||||
hc_fopen (&fp, filename, "rb");
|
||||
|
||||
// while (!feof (fd))
|
||||
while (!hc_feof (&fp))
|
||||
{
|
||||
// const size_t nread = fread (buf, 1, FBUFSZ, fd);
|
||||
const size_t nread = hc_fread (buf, 1, FBUFSZ, &fp);
|
||||
|
||||
XXH64_update (state, buf, nread);
|
||||
}
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
const u64 hash = XXH64_digest (state);
|
||||
@ -615,10 +611,8 @@ u32 brain_auth_challenge (void)
|
||||
|
||||
static const char *urandom = "/dev/urandom";
|
||||
|
||||
// FILE *fd = fopen (urandom, "rb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fd == NULL)
|
||||
if (hc_fopen (&fp, urandom, "rb") == false)
|
||||
{
|
||||
brain_logging (stderr, 0, "%s: %s\n", urandom, strerror (errno));
|
||||
@ -626,18 +620,15 @@ u32 brain_auth_challenge (void)
|
||||
return val;
|
||||
}
|
||||
|
||||
// if (fread (&val, sizeof (val), 1, fd) != 1)
|
||||
if (hc_fread (&val, sizeof (val), 1, &fp) != 1)
|
||||
{
|
||||
brain_logging (stderr, 0, "%s: %s\n", urandom, strerror (errno));
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
#endif
|
||||
@ -1606,10 +1597,8 @@ bool brain_server_read_hash_dump (brain_server_db_hash_t *brain_server_db_hash,
|
||||
return false;
|
||||
}
|
||||
|
||||
// FILE *fd = fopen (file, "rb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fd == NULL)
|
||||
if (hc_fopen (&fp, file, "rb") == false)
|
||||
{
|
||||
brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno));
|
||||
@ -1624,20 +1613,17 @@ bool brain_server_read_hash_dump (brain_server_db_hash_t *brain_server_db_hash,
|
||||
{
|
||||
brain_logging (stderr, 0, "%s\n", MSG_ENOMEM);
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// const size_t nread = fread (brain_server_db_hash->long_buf, sizeof (brain_server_hash_long_t), temp_cnt, fd);
|
||||
const size_t nread = hc_fread (brain_server_db_hash->long_buf, sizeof (brain_server_hash_long_t), temp_cnt, &fp);
|
||||
|
||||
if (nread != (size_t) temp_cnt)
|
||||
{
|
||||
brain_logging (stderr, 0, "%s: only %" PRIu64 " bytes read\n", file, (u64) nread * sizeof (brain_server_hash_long_t));
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return false;
|
||||
@ -1647,7 +1633,6 @@ bool brain_server_read_hash_dump (brain_server_db_hash_t *brain_server_db_hash,
|
||||
|
||||
brain_server_db_hash->write_hashes = false;
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
}
|
||||
|
||||
@ -1668,10 +1653,8 @@ bool brain_server_write_hash_dump (brain_server_db_hash_t *brain_server_db_hash,
|
||||
|
||||
// write to file
|
||||
|
||||
// FILE *fd = fopen (file, "wb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fd == NULL)
|
||||
if (hc_fopen (&fp, file, "wb") == false)
|
||||
{
|
||||
brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno));
|
||||
@ -1682,20 +1665,17 @@ bool brain_server_write_hash_dump (brain_server_db_hash_t *brain_server_db_hash,
|
||||
{
|
||||
fp.is_gzip = false;
|
||||
|
||||
// const size_t nwrite = fwrite (brain_server_db_hash->long_buf, sizeof (brain_server_hash_long_t), brain_server_db_hash->long_cnt, fd);
|
||||
const size_t nwrite = hc_fwrite (brain_server_db_hash->long_buf, sizeof (brain_server_hash_long_t), brain_server_db_hash->long_cnt, &fp);
|
||||
|
||||
if (nwrite != (size_t) brain_server_db_hash->long_cnt)
|
||||
{
|
||||
brain_logging (stderr, 0, "%s: only %" PRIu64 " bytes written\n", file, (u64) nwrite * sizeof (brain_server_hash_long_t));
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
brain_server_db_hash->write_hashes = false;
|
||||
@ -1818,10 +1798,8 @@ bool brain_server_read_attack_dump (brain_server_db_attack_t *brain_server_db_at
|
||||
return false;
|
||||
}
|
||||
|
||||
// FILE *fd = fopen (file, "rb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fd == NULL)
|
||||
if (hc_fopen (&fp, file, "rb") == false)
|
||||
{
|
||||
brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno));
|
||||
@ -1836,20 +1814,17 @@ bool brain_server_read_attack_dump (brain_server_db_attack_t *brain_server_db_at
|
||||
{
|
||||
brain_logging (stderr, 0, "%s\n", MSG_ENOMEM);
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// const size_t nread = fread (brain_server_db_attack->long_buf, sizeof (brain_server_attack_long_t), temp_cnt, fd);
|
||||
const size_t nread = hc_fread (brain_server_db_attack->long_buf, sizeof (brain_server_attack_long_t), temp_cnt, &fp);
|
||||
|
||||
if (nread != (size_t) temp_cnt)
|
||||
{
|
||||
brain_logging (stderr, 0, "%s: only %" PRIu64 " bytes read\n", file, (u64) nread * sizeof (brain_server_attack_long_t));
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return false;
|
||||
@ -1859,7 +1834,6 @@ bool brain_server_read_attack_dump (brain_server_db_attack_t *brain_server_db_at
|
||||
|
||||
brain_server_db_attack->write_attacks = false;
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
}
|
||||
|
||||
@ -1880,10 +1854,8 @@ bool brain_server_write_attack_dump (brain_server_db_attack_t *brain_server_db_a
|
||||
|
||||
// write to file
|
||||
|
||||
// FILE *fd = fopen (file, "wb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fd == NULL)
|
||||
if (hc_fopen (&fp, file, "wb") == false)
|
||||
{
|
||||
brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno));
|
||||
@ -1896,20 +1868,17 @@ bool brain_server_write_attack_dump (brain_server_db_attack_t *brain_server_db_a
|
||||
|
||||
// storing should not include reserved attacks only finished
|
||||
|
||||
// const size_t nwrite = fwrite (brain_server_db_attack->long_buf, sizeof (brain_server_attack_long_t), brain_server_db_attack->long_cnt, fd);
|
||||
const size_t nwrite = hc_fwrite (brain_server_db_attack->long_buf, sizeof (brain_server_attack_long_t), brain_server_db_attack->long_cnt, &fp);
|
||||
|
||||
if (nwrite != (size_t) brain_server_db_attack->long_cnt)
|
||||
{
|
||||
brain_logging (stderr, 0, "%s: only %" PRIu64 " bytes written\n", file, (u64) nwrite * sizeof (brain_server_attack_long_t));
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
brain_server_db_attack->write_attacks = false;
|
||||
|
@ -92,7 +92,6 @@ int cpu_crc32 (const char *filename, u8 keytab[64])
|
||||
{
|
||||
u32 crc = ~0u;
|
||||
|
||||
// FILE *fd = fopen (filename, "rb");
|
||||
HCFILE fp;
|
||||
|
||||
hc_fopen (&fp, filename, "rb");
|
||||
@ -103,7 +102,6 @@ int cpu_crc32 (const char *filename, u8 keytab[64])
|
||||
|
||||
size_t nread = hc_fread (buf, sizeof (u8), MAX_KEY_SIZE, &fp);
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
size_t kpos = 0;
|
||||
|
@ -37,16 +37,13 @@ static void debugfile_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_
|
||||
|
||||
if (needs_hexify == 1)
|
||||
{
|
||||
// fprintf (debugfile_ctx->fp, "$HEX[");
|
||||
hc_fprintf (debugfile_ctx->fp, "$HEX[");
|
||||
|
||||
for (u32 i = 0; i < plain_len; i++)
|
||||
{
|
||||
// fprintf (debugfile_ctx->fp, "%02x", plain_ptr[i]);
|
||||
hc_fprintf (debugfile_ctx->fp, "%02x", plain_ptr[i]);
|
||||
}
|
||||
|
||||
// fprintf (debugfile_ctx->fp, "]");
|
||||
hc_fprintf (debugfile_ctx->fp, "]");
|
||||
}
|
||||
else
|
||||
@ -67,7 +64,6 @@ void debugfile_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *rule_buf, con
|
||||
{
|
||||
debugfile_format_plain (hashcat_ctx, orig_plain_ptr, orig_plain_len);
|
||||
|
||||
// if ((debug_mode == 3) || (debug_mode == 4)) fputc (':', debugfile_ctx->fp);
|
||||
if ((debug_mode == 3) || (debug_mode == 4)) hc_fputc (':', debugfile_ctx->fp);
|
||||
}
|
||||
|
||||
@ -75,7 +71,6 @@ void debugfile_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *rule_buf, con
|
||||
|
||||
if (debug_mode == 4)
|
||||
{
|
||||
// fputc (':', debugfile_ctx->fp);
|
||||
hc_fputc (':', debugfile_ctx->fp);
|
||||
|
||||
debugfile_format_plain (hashcat_ctx, mod_plain_ptr, mod_plain_len);
|
||||
@ -112,10 +107,8 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (debugfile_ctx->filename)
|
||||
{
|
||||
// FILE *fp = fopen (debugfile_ctx->filename, "ab");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL)
|
||||
if (hc_fopen (&fp, debugfile_ctx->filename, "ab") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Could not open --debug-file file for writing.");
|
||||
@ -125,10 +118,8 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
fp.is_gzip = false;
|
||||
|
||||
// if (lock_file (fp) == -1)
|
||||
if (lock_file (fp.f.fp) == -1)
|
||||
if (lock_file (fp.pfp) == -1)
|
||||
{
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
event_log_error (hashcat_ctx, "%s: %s", debugfile_ctx->filename, strerror (errno));
|
||||
@ -136,16 +127,14 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// debugfile_ctx->fp = fp;
|
||||
debugfile_ctx->fp = &fp;
|
||||
}
|
||||
else
|
||||
{
|
||||
HCFILE fp_tmp;
|
||||
fp_tmp.is_gzip = false;
|
||||
fp_tmp.f.fp = stdout;
|
||||
fp_tmp.pfp = stdout;
|
||||
|
||||
// debugfile_ctx->fp = stdout;
|
||||
debugfile_ctx->fp = &fp_tmp;
|
||||
}
|
||||
|
||||
@ -160,7 +149,6 @@ void debugfile_destroy (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (debugfile_ctx->filename)
|
||||
{
|
||||
// fclose (debugfile_ctx->fp);
|
||||
hc_fclose (debugfile_ctx->fp);
|
||||
}
|
||||
|
||||
|
@ -96,10 +96,8 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (hashconfig->dictstat_disable == true) return;
|
||||
|
||||
// FILE *fp = fopen (dictstat_ctx->filename, "rb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL)
|
||||
if (hc_fopen (&fp, dictstat_ctx->filename, "rb") == false)
|
||||
{
|
||||
// first run, file does not exist, do not error out
|
||||
@ -119,7 +117,6 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: Invalid header", dictstat_ctx->filename);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return;
|
||||
@ -132,7 +129,6 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: Invalid header, ignoring content", dictstat_ctx->filename);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return;
|
||||
@ -142,7 +138,6 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: Invalid header, ignoring content", dictstat_ctx->filename);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return;
|
||||
@ -152,7 +147,6 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
event_log_warning (hashcat_ctx, "%s: Outdated header version, ignoring content", dictstat_ctx->filename);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return;
|
||||
@ -160,7 +154,6 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
// parse data
|
||||
|
||||
// while (!feof (fp))
|
||||
while (!hc_feof (&fp))
|
||||
{
|
||||
dictstat_t d;
|
||||
@ -179,7 +172,6 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
}
|
||||
|
||||
@ -192,10 +184,8 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (hashconfig->dictstat_disable == true) return 0;
|
||||
|
||||
// FILE *fp = fopen (dictstat_ctx->filename, "wb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL)
|
||||
if (hc_fopen (&fp, dictstat_ctx->filename, "wb") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno));
|
||||
@ -205,10 +195,8 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
fp.is_gzip = false;
|
||||
|
||||
// if (lock_file (fp) == -1)
|
||||
if (lock_file (fp.f.fp) == -1)
|
||||
if (lock_file (fp.pfp) == -1)
|
||||
{
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno));
|
||||
@ -231,7 +219,6 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hc_fwrite (dictstat_ctx->base, sizeof (dictstat_t), dictstat_ctx->cnt, &fp);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return 0;
|
||||
|
13
src/hashes.c
13
src/hashes.c
@ -184,10 +184,8 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
char separator = hashconfig->separator;
|
||||
|
||||
// FILE *fp = fopen (new_hashfile, "wb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL)
|
||||
if (hc_fopen (&fp, new_hashfile, "wb") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", new_hashfile, strerror (errno));
|
||||
@ -200,10 +198,8 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
fp.is_gzip = false;
|
||||
|
||||
// if (lock_file (fp) == -1)
|
||||
if (lock_file (fp.f.fp) == -1)
|
||||
if (lock_file (fp.pfp) == -1)
|
||||
{
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
event_log_error (hashcat_ctx, "%s: %s", new_hashfile, strerror (errno));
|
||||
@ -246,10 +242,8 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
u32 i;
|
||||
|
||||
// for (i = 0; i < user->user_len; i++) fputc (user->user_name[i], fp);
|
||||
for (i = 0; i < user->user_len; i++) hc_fputc (user->user_name[i], &fp);
|
||||
|
||||
// fputc (separator, fp);
|
||||
hc_fputc (separator, &fp);
|
||||
}
|
||||
|
||||
@ -257,7 +251,6 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
out_buf[out_len] = 0;
|
||||
|
||||
// fprintf (fp, "%s" EOL, out_buf);
|
||||
hc_fprintf (&fp, "%s" EOL, out_buf);
|
||||
}
|
||||
}
|
||||
@ -265,10 +258,8 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hcfree (out_buf);
|
||||
|
||||
// fflush (fp);
|
||||
hc_fflush (&fp);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
unlink (old_hashfile);
|
||||
@ -1805,6 +1796,8 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hc_fopen (&fp, tmpfile_bin, "wb");
|
||||
|
||||
fp.is_gzip = false;
|
||||
|
||||
const size_t st_hash_len = strlen (hashconfig->st_hash);
|
||||
|
||||
for (size_t i = 0; i < st_hash_len; i += 2)
|
||||
|
35
src/hwmon.c
35
src/hwmon.c
@ -110,10 +110,8 @@ static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int
|
||||
|
||||
hcfree (syspath);
|
||||
|
||||
// FILE *fd_cur = fopen (path_cur, "r");
|
||||
HCFILE fp_cur;
|
||||
|
||||
// if (fd_cur == NULL)
|
||||
if (hc_fopen (&fp_cur, path_cur, "r") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", path_cur, strerror (errno));
|
||||
@ -126,10 +124,8 @@ static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int
|
||||
|
||||
int pwm1_cur = 0;
|
||||
|
||||
// if (fscanf (fd_cur, "%d", &pwm1_cur) != 1)
|
||||
if (hc_fscanf (&fp_cur, "%d", &pwm1_cur) != 1)
|
||||
{
|
||||
// fclose (fd_cur);
|
||||
hc_fclose (&fp_cur);
|
||||
|
||||
event_log_error (hashcat_ctx, "%s: unexpected data.", path_cur);
|
||||
@ -140,13 +136,10 @@ static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int
|
||||
return -1;
|
||||
}
|
||||
|
||||
// fclose (fd_cur);
|
||||
hc_fclose (&fp_cur);
|
||||
|
||||
// FILE *fd_max = fopen (path_max, "r");
|
||||
HCFILE fp_max;
|
||||
|
||||
// if (fd_max == NULL)
|
||||
if (hc_fopen (&fp_max, path_max, "r") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", path_max, strerror (errno));
|
||||
@ -159,10 +152,8 @@ static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int
|
||||
|
||||
int pwm1_max = 0;
|
||||
|
||||
// if (fscanf (fd_max, "%d", &pwm1_max) != 1)
|
||||
if (hc_fscanf (&fp_max, "%d", &pwm1_max) != 1)
|
||||
{
|
||||
// fclose (fd_max);
|
||||
hc_fclose (&fp_max);
|
||||
|
||||
event_log_error (hashcat_ctx, "%s: unexpected data.", path_max);
|
||||
@ -173,7 +164,6 @@ static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int
|
||||
return -1;
|
||||
}
|
||||
|
||||
// fclose (fd_max);
|
||||
hc_fclose (&fp_max);
|
||||
|
||||
if (pwm1_max == 0)
|
||||
@ -210,10 +200,8 @@ static int hm_SYSFS_get_temperature_current (hashcat_ctx_t *hashcat_ctx, const i
|
||||
|
||||
hcfree (syspath);
|
||||
|
||||
// FILE *fd = fopen (path, "r");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fd == NULL)
|
||||
if (hc_fopen (&fp, path, "r") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno));
|
||||
@ -225,10 +213,8 @@ static int hm_SYSFS_get_temperature_current (hashcat_ctx_t *hashcat_ctx, const i
|
||||
|
||||
int temperature = 0;
|
||||
|
||||
// if (fscanf (fd, "%d", &temperature) != 1)
|
||||
if (hc_fscanf (&fp, "%d", &temperature) != 1)
|
||||
{
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
event_log_error (hashcat_ctx, "%s: unexpected data.", path);
|
||||
@ -238,7 +224,6 @@ static int hm_SYSFS_get_temperature_current (hashcat_ctx_t *hashcat_ctx, const i
|
||||
return -1;
|
||||
}
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
*val = temperature / 1000;
|
||||
@ -260,10 +245,8 @@ static int hm_SYSFS_get_pp_dpm_sclk (hashcat_ctx_t *hashcat_ctx, const int backe
|
||||
|
||||
hcfree (syspath);
|
||||
|
||||
// FILE *fd = fopen (path, "r");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fd == NULL)
|
||||
if (hc_fopen (&fp, path, "r") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno));
|
||||
@ -275,12 +258,10 @@ static int hm_SYSFS_get_pp_dpm_sclk (hashcat_ctx_t *hashcat_ctx, const int backe
|
||||
|
||||
int clockfreq = 0;
|
||||
|
||||
// while (!feof (fd))
|
||||
while (!hc_feof (&fp))
|
||||
{
|
||||
char buf[HCBUFSIZ_TINY];
|
||||
char buf[HCBUFSIZ_TINY] = { 0 };
|
||||
|
||||
// char *ptr = fgets (buf, sizeof (buf), fd);
|
||||
char *ptr = hc_fgets (buf, sizeof (buf), &fp);
|
||||
|
||||
if (ptr == NULL) continue;
|
||||
@ -298,7 +279,6 @@ static int hm_SYSFS_get_pp_dpm_sclk (hashcat_ctx_t *hashcat_ctx, const int backe
|
||||
if (rc == 2) break;
|
||||
}
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
*val = clockfreq;
|
||||
@ -320,10 +300,8 @@ static int hm_SYSFS_get_pp_dpm_mclk (hashcat_ctx_t *hashcat_ctx, const int backe
|
||||
|
||||
hcfree (syspath);
|
||||
|
||||
// FILE *fd = fopen (path, "r");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fd == NULL)
|
||||
if (hc_fopen (&fp, path, "r") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno));
|
||||
@ -335,12 +313,10 @@ static int hm_SYSFS_get_pp_dpm_mclk (hashcat_ctx_t *hashcat_ctx, const int backe
|
||||
|
||||
int clockfreq = 0;
|
||||
|
||||
// while (!feof (fd))
|
||||
while (!hc_feof (&fp))
|
||||
{
|
||||
char buf[HCBUFSIZ_TINY];
|
||||
|
||||
// char *ptr = fgets (buf, sizeof (buf), fd);
|
||||
char *ptr = hc_fgets (buf, sizeof (buf), &fp);
|
||||
|
||||
if (ptr == NULL) continue;
|
||||
@ -358,7 +334,6 @@ static int hm_SYSFS_get_pp_dpm_mclk (hashcat_ctx_t *hashcat_ctx, const int backe
|
||||
if (rc == 2) break;
|
||||
}
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
*val = clockfreq;
|
||||
@ -380,10 +355,8 @@ static int hm_SYSFS_get_pp_dpm_pcie (hashcat_ctx_t *hashcat_ctx, const int backe
|
||||
|
||||
hcfree (syspath);
|
||||
|
||||
// FILE *fd = fopen (path, "r");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fd == NULL)
|
||||
if (hc_fopen (&fp, path, "r") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno));
|
||||
@ -395,12 +368,10 @@ static int hm_SYSFS_get_pp_dpm_pcie (hashcat_ctx_t *hashcat_ctx, const int backe
|
||||
|
||||
int lanes = 0;
|
||||
|
||||
// while (!feof (fd))
|
||||
while (!hc_feof (&fp))
|
||||
{
|
||||
char buf[HCBUFSIZ_TINY];
|
||||
|
||||
// char *ptr = fgets (buf, sizeof (buf), fd);
|
||||
char *ptr = hc_fgets (buf, sizeof (buf), &fp);
|
||||
|
||||
if (ptr == NULL) continue;
|
||||
@ -419,7 +390,6 @@ static int hm_SYSFS_get_pp_dpm_pcie (hashcat_ctx_t *hashcat_ctx, const int backe
|
||||
if (rc == 3) break;
|
||||
}
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
*val = lanes;
|
||||
@ -490,10 +460,8 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (!nvml->lib)
|
||||
{
|
||||
// FILE *nvml_lib = fopen ("/proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/NVIDIA Corporation/Global/NVSMI/NVSMIPATH", "rb");
|
||||
HCFILE nvml_lib;
|
||||
|
||||
// if (nvml_lib == NULL)
|
||||
if (hc_fopen (&nvml_lib, "/proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/NVIDIA Corporation/Global/NVSMI/NVSMIPATH", "rb") == false)
|
||||
{
|
||||
//if (user_options->quiet == false)
|
||||
@ -508,7 +476,6 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hc_fread (nvml_winpath, 100, 1, &nvml_lib);
|
||||
|
||||
// fclose (nvml_lib);
|
||||
hc_fclose (&nvml_lib);
|
||||
|
||||
ssize_t size = cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_PROC_CYGDRIVE, nvml_winpath, NULL, 0);
|
||||
|
@ -43,10 +43,8 @@ void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
||||
|
||||
if (logfile_ctx->enabled == false) return;
|
||||
|
||||
// FILE *fp = fopen (logfile_ctx->logfile, "ab");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL)
|
||||
if (hc_fopen (&fp, logfile_ctx->logfile, "ab") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", logfile_ctx->logfile, strerror (errno));
|
||||
@ -56,24 +54,20 @@ void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
||||
|
||||
fp.is_gzip = false;
|
||||
|
||||
// lock_file (fp);
|
||||
lock_file (fp.f.fp);
|
||||
lock_file (fp.pfp);
|
||||
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, fmt);
|
||||
|
||||
// vfprintf (fp, fmt, ap);
|
||||
hc_vfprintf (&fp, fmt, ap);
|
||||
|
||||
va_end (ap);
|
||||
|
||||
hc_fwrite (EOL, strlen (EOL), 1, &fp);
|
||||
|
||||
// fflush (fp);
|
||||
hc_fflush (&fp);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
}
|
||||
|
||||
|
@ -38,16 +38,13 @@ static void loopback_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_p
|
||||
|
||||
if (needs_hexify == 1)
|
||||
{
|
||||
// fprintf (loopback_ctx->fp, "$HEX[");
|
||||
hc_fprintf (loopback_ctx->fp, "$HEX[");
|
||||
|
||||
for (u32 i = 0; i < plain_len; i++)
|
||||
{
|
||||
// fprintf (loopback_ctx->fp, "%02x", plain_ptr[i]);
|
||||
hc_fprintf (loopback_ctx->fp, "%02x", plain_ptr[i]);
|
||||
}
|
||||
|
||||
// fprintf (loopback_ctx->fp, "]");
|
||||
hc_fprintf (loopback_ctx->fp, "]");
|
||||
}
|
||||
else
|
||||
@ -108,10 +105,8 @@ int loopback_write_open (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hc_asprintf (&loopback_ctx->filename, "%s/%s.%d_%u", induct_ctx->root_directory, LOOPBACK_FILE, (int) now, random_num);
|
||||
|
||||
// FILE *fp = fopen (loopback_ctx->filename, "ab");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL)
|
||||
if (hc_fopen (&fp, loopback_ctx->filename, "ab") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", loopback_ctx->filename, strerror (errno));
|
||||
@ -121,7 +116,6 @@ int loopback_write_open (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
fp.is_gzip = false;
|
||||
|
||||
// loopback_ctx->fp = fp;
|
||||
loopback_ctx->fp = &fp;
|
||||
|
||||
loopback_ctx->unused = true;
|
||||
@ -148,7 +142,6 @@ void loopback_write_close (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (loopback_ctx->fp == NULL) return;
|
||||
|
||||
// fclose (loopback_ctx->fp);
|
||||
hc_fclose (loopback_ctx->fp);
|
||||
|
||||
if (loopback_ctx->unused == true)
|
||||
@ -163,21 +156,17 @@ void loopback_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, con
|
||||
|
||||
if (loopback_ctx->enabled == false) return;
|
||||
|
||||
// FILE *fp = loopback_ctx->fp;
|
||||
HCFILE *fp = loopback_ctx->fp;
|
||||
|
||||
loopback_format_plain (hashcat_ctx, plain_ptr, plain_len);
|
||||
|
||||
// lock_file (fp);
|
||||
lock_file (fp->f.fp);
|
||||
lock_file (fp->pfp);
|
||||
|
||||
hc_fwrite (EOL, strlen (EOL), 1, fp);
|
||||
|
||||
// fflush (fp);
|
||||
hc_fflush (fp);
|
||||
|
||||
// if (unlock_file (fp))
|
||||
if (unlock_file (fp->f.fp))
|
||||
if (unlock_file (fp->pfp))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: Failed to unlock file", loopback_ctx->filename);
|
||||
}
|
||||
|
29
src/main.c
29
src/main.c
@ -28,33 +28,23 @@
|
||||
int _dowildcard = -1;
|
||||
#endif
|
||||
|
||||
//static void main_log_clear_line (MAYBE_UNUSED const size_t prev_len, MAYBE_UNUSED FILE *fp)
|
||||
static void main_log_clear_line (MAYBE_UNUSED const size_t prev_len, MAYBE_UNUSED HCFILE *fp)
|
||||
{
|
||||
#if defined (_WIN)
|
||||
|
||||
// fputc ('\r', fp);
|
||||
hc_fputc ('\r', fp);
|
||||
|
||||
for (size_t i = 0; i < prev_len; i++)
|
||||
{
|
||||
// fputc (' ', fp);
|
||||
hc_fputc (' ', fp);
|
||||
}
|
||||
for (size_t i = 0; i < prev_len; i++) hc_fputc (' ', fp);
|
||||
|
||||
// fputc ('\r', fp);
|
||||
hc_fputc ('\r', fp);
|
||||
|
||||
#else
|
||||
|
||||
// fputs ("\033[2K\r", fp);
|
||||
hc_fprintf(fp, "\033[2K\r");
|
||||
// fputs ("\033[2K\r", fp);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
//static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
|
||||
static void main_log (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const int loglevel)
|
||||
{
|
||||
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
|
||||
@ -107,7 +97,7 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const int loglevel
|
||||
#else
|
||||
switch (loglevel)
|
||||
{
|
||||
case LOGLEVEL_INFO: break;
|
||||
case LOGLEVEL_INFO: break;
|
||||
case LOGLEVEL_WARNING: hc_fwrite ("\033[33m", 5, 1, fp); break;
|
||||
case LOGLEVEL_ERROR: hc_fwrite ("\033[31m", 5, 1, fp); break;
|
||||
case LOGLEVEL_ADVICE: hc_fwrite ("\033[33m", 5, 1, fp); break;
|
||||
@ -131,7 +121,7 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const int loglevel
|
||||
#else
|
||||
switch (loglevel)
|
||||
{
|
||||
case LOGLEVEL_INFO: break;
|
||||
case LOGLEVEL_INFO: break;
|
||||
case LOGLEVEL_WARNING: hc_fwrite ("\033[0m", 4, 1, fp); break;
|
||||
case LOGLEVEL_ERROR: hc_fwrite ("\033[0m", 4, 1, fp); break;
|
||||
case LOGLEVEL_ADVICE: hc_fwrite ("\033[0m", 4, 1, fp); break;
|
||||
@ -152,7 +142,6 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const int loglevel
|
||||
}
|
||||
}
|
||||
|
||||
// fflush (fp);
|
||||
hc_fflush (fp);
|
||||
}
|
||||
|
||||
@ -164,9 +153,8 @@ static void main_log_advice (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUS
|
||||
|
||||
HCFILE fp;
|
||||
fp.is_gzip = false;
|
||||
fp.f.fp = stdout;
|
||||
fp.pfp = stdout;
|
||||
|
||||
// main_log (hashcat_ctx, stdout, LOGLEVEL_ADVICE);
|
||||
main_log (hashcat_ctx, &fp, LOGLEVEL_ADVICE);
|
||||
}
|
||||
|
||||
@ -174,9 +162,8 @@ static void main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED
|
||||
{
|
||||
HCFILE fp;
|
||||
fp.is_gzip = false;
|
||||
fp.f.fp = stdout;
|
||||
fp.pfp = stdout;
|
||||
|
||||
// main_log (hashcat_ctx, stdout, LOGLEVEL_INFO);
|
||||
main_log (hashcat_ctx, &fp, LOGLEVEL_INFO);
|
||||
}
|
||||
|
||||
@ -184,9 +171,8 @@ static void main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNU
|
||||
{
|
||||
HCFILE fp;
|
||||
fp.is_gzip = false;
|
||||
fp.f.fp = stdout;
|
||||
fp.pfp = stdout;
|
||||
|
||||
// main_log (hashcat_ctx, stdout, LOGLEVEL_WARNING);
|
||||
main_log (hashcat_ctx, &fp, LOGLEVEL_WARNING);
|
||||
}
|
||||
|
||||
@ -194,9 +180,8 @@ static void main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSE
|
||||
{
|
||||
HCFILE fp;
|
||||
fp.is_gzip = false;
|
||||
fp.f.fp = stderr;
|
||||
fp.pfp = stderr;
|
||||
|
||||
// main_log (hashcat_ctx, stderr, LOGLEVEL_ERROR);
|
||||
main_log (hashcat_ctx, &fp, LOGLEVEL_ERROR);
|
||||
}
|
||||
|
||||
|
41
src/mpsp.c
41
src/mpsp.c
@ -582,10 +582,8 @@ static void mp_setup_sys (cs_t *mp_sys)
|
||||
|
||||
static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, const char *buf, const u32 userindex)
|
||||
{
|
||||
// FILE *fp = fopen (buf, "rb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL) // feof() in case if file is empty
|
||||
if (hc_fopen (&fp, buf, "rb") == false)
|
||||
{
|
||||
const int rc = mp_expand (hashcat_ctx, buf, strlen (buf), mp_sys, mp_usr, userindex, 1);
|
||||
@ -598,18 +596,15 @@ static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr,
|
||||
|
||||
const size_t nread = hc_fread (mp_file, 1, sizeof (mp_file) - 1, &fp);
|
||||
|
||||
// if (!feof (fp))
|
||||
if (!hc_feof (&fp))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: Custom charset file is too large.", buf);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
if (nread == 0)
|
||||
@ -715,10 +710,8 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// FILE *fd = fopen (hcstat, "rb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fd == NULL)
|
||||
if (hc_fopen (&fp, hcstat, "rb") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", hcstat, strerror (errno));
|
||||
@ -734,7 +727,6 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: Could not read data.", hcstat);
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
hcfree (inbuf);
|
||||
@ -742,7 +734,6 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// fclose (fd);
|
||||
hc_fclose (&fp);
|
||||
|
||||
u8 *outbuf = (u8 *) hcmalloc (SP_FILESZ);
|
||||
@ -1469,10 +1460,8 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (hc_path_is_file (arg) == true)
|
||||
{
|
||||
// FILE *mask_fp = fopen (arg, "r");
|
||||
HCFILE mask_fp;
|
||||
|
||||
// if (mask_fp == NULL)
|
||||
if (hc_fopen (&mask_fp, arg, "r") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno));
|
||||
@ -1482,12 +1471,6 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
// workaround for new fgetl
|
||||
/* HCFILE fp;
|
||||
fp.is_gzip = 0;
|
||||
fp.f.fp = mask_fp;
|
||||
*/
|
||||
// while (!feof (mask_fp))
|
||||
while (!hc_feof (&mask_fp))
|
||||
{
|
||||
const size_t line_len = fgetl (&mask_fp, line_buf);
|
||||
@ -1513,7 +1496,6 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
// fclose (mask_fp);
|
||||
hc_fclose (&mask_fp);
|
||||
|
||||
return -1;
|
||||
@ -1522,7 +1504,6 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hcfree (line_buf);
|
||||
|
||||
// fclose (mask_fp);
|
||||
hc_fclose (&mask_fp);
|
||||
}
|
||||
else
|
||||
@ -1572,10 +1553,8 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
mask_ctx->mask_from_file = true;
|
||||
|
||||
// FILE *mask_fp = fopen (arg, "r");
|
||||
HCFILE mask_fp;
|
||||
|
||||
// if (mask_fp == NULL)
|
||||
if (hc_fopen (&mask_fp, arg, "r") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno));
|
||||
@ -1584,14 +1563,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
}
|
||||
|
||||
char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
||||
/*
|
||||
// workaround for new fgetl
|
||||
HCFILE fp;
|
||||
fp.is_gzip = 0;
|
||||
fp.f.fp = mask_fp;
|
||||
|
||||
while (!feof (mask_fp))
|
||||
*/
|
||||
while (!hc_feof (&mask_fp))
|
||||
{
|
||||
const size_t line_len = fgetl (&mask_fp, line_buf);
|
||||
@ -1617,7 +1589,6 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
// fclose (mask_fp);
|
||||
hc_fclose (&mask_fp);
|
||||
|
||||
return -1;
|
||||
@ -1626,7 +1597,6 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hcfree (line_buf);
|
||||
|
||||
// fclose (mask_fp);
|
||||
hc_fclose (&mask_fp);
|
||||
}
|
||||
else
|
||||
@ -1657,10 +1627,8 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
mask_ctx->mask_from_file = true;
|
||||
|
||||
// FILE *mask_fp = fopen (arg, "r");
|
||||
HCFILE mask_fp;
|
||||
|
||||
// if (mask_fp == NULL)
|
||||
if (hc_fopen (&mask_fp, arg, "r") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno));
|
||||
@ -1669,14 +1637,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
}
|
||||
|
||||
char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
||||
/*
|
||||
// workaround for new fgetl
|
||||
HCFILE fp;
|
||||
fp.is_gzip = 0;
|
||||
fp.f.fp = mask_fp;
|
||||
|
||||
while (!feof (mask_fp))
|
||||
*/
|
||||
while (!hc_feof (&mask_fp))
|
||||
{
|
||||
const size_t line_len = fgetl (&mask_fp, line_buf);
|
||||
@ -1702,7 +1663,6 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
// fclose (mask_fp);
|
||||
hc_fclose (&mask_fp);
|
||||
|
||||
return -1;
|
||||
@ -1711,7 +1671,6 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hcfree (line_buf);
|
||||
|
||||
// fclose (mask_fp);
|
||||
hc_fclose (&mask_fp);
|
||||
}
|
||||
else
|
||||
|
@ -390,10 +390,8 @@ int outfile_write_open (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (outfile_ctx->filename == NULL) return 0;
|
||||
|
||||
// FILE *fp = fopen (outfile_ctx->filename, "ab");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL)
|
||||
if (hc_fopen (&fp, outfile_ctx->filename, "ab") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", outfile_ctx->filename, strerror (errno));
|
||||
@ -403,10 +401,8 @@ int outfile_write_open (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
fp.is_gzip = false;
|
||||
|
||||
// if (lock_file (fp) == -1)
|
||||
if (lock_file (fp.f.fp) == -1)
|
||||
if (lock_file (fp.pfp) == -1)
|
||||
{
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
event_log_error (hashcat_ctx, "%s: %s", outfile_ctx->filename, strerror (errno));
|
||||
@ -414,7 +410,6 @@ int outfile_write_open (hashcat_ctx_t *hashcat_ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// outfile_ctx->fp = fp;
|
||||
outfile_ctx->fp = &fp;
|
||||
|
||||
return 0;
|
||||
@ -426,7 +421,6 @@ void outfile_write_close (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (outfile_ctx->fp == NULL) return;
|
||||
|
||||
// fclose (outfile_ctx->fp);
|
||||
hc_fclose (outfile_ctx->fp);
|
||||
}
|
||||
|
||||
|
@ -155,20 +155,16 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
for (int j = 0; j < out_cnt; j++)
|
||||
{
|
||||
// FILE *fp = fopen (out_info[j].file_name, "rb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL) continue;
|
||||
if (hc_fopen (&fp, out_info[j].file_name, "rb") == false) continue;
|
||||
|
||||
//hc_thread_mutex_lock (status_ctx->mux_display);
|
||||
|
||||
struct stat outfile_stat;
|
||||
|
||||
// if (fstat (fileno (fp), &outfile_stat))
|
||||
if (fstat (hc_fileno (&fp), &outfile_stat))
|
||||
{
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
continue;
|
||||
@ -180,21 +176,13 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
|
||||
out_info[j].seek = 0;
|
||||
}
|
||||
|
||||
// fseeko (fp, out_info[j].seek, SEEK_SET);
|
||||
hc_fseek (&fp, out_info[j].seek, SEEK_SET);
|
||||
|
||||
char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
// large portion of the following code is the same as in potfile_remove_parse
|
||||
// maybe subject of a future optimization
|
||||
/*
|
||||
// workaround for new fgetl
|
||||
HCFILE fp_tmp;
|
||||
fp_tmp.is_gzip = 0;
|
||||
fp_tmp.f.fp = fp;
|
||||
|
||||
while (!feof (fp))
|
||||
*/
|
||||
while (!hc_feof (&fp))
|
||||
{
|
||||
size_t line_len = fgetl (&fp, line_buf);
|
||||
@ -319,12 +307,10 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hcfree (line_buf);
|
||||
|
||||
// out_info[j].seek = ftello (fp);
|
||||
out_info[j].seek = hc_ftell (&fp);
|
||||
|
||||
//hc_thread_mutex_unlock (status_ctx->mux_display);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
if (status_ctx->shutdown_inner == true) break;
|
||||
|
@ -16,17 +16,14 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
char *pidfile_filename = pidfile_ctx->filename;
|
||||
|
||||
// FILE *fp = fopen (pidfile_filename, "rb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL) return 0;
|
||||
if (hc_fopen (&fp, pidfile_filename, "rb") == false) return 0;
|
||||
|
||||
pidfile_data_t *pd = (pidfile_data_t *) hcmalloc (sizeof (pidfile_data_t));
|
||||
|
||||
const size_t nread = hc_fread (pd, sizeof (pidfile_data_t), 1, &fp);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
if (nread != 1)
|
||||
@ -156,10 +153,8 @@ static int write_pidfile (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
char *pidfile_filename = pidfile_ctx->filename;
|
||||
|
||||
// FILE *fp = fopen (pidfile_filename, "wb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL)
|
||||
if (hc_fopen (&fp, pidfile_filename, "wb") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", pidfile_filename, strerror (errno));
|
||||
@ -171,10 +166,8 @@ static int write_pidfile (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hc_fwrite (pd, sizeof (pidfile_data_t), 1, &fp);
|
||||
|
||||
// fflush (fp);
|
||||
hc_fflush (&fp);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return 0;
|
||||
|
@ -528,7 +528,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
|
||||
// workaround for new fgetl
|
||||
HCFILE fp;
|
||||
fp.is_gzip = false;
|
||||
fp.f.fp = potfile_ctx->fp;
|
||||
fp.pfp = potfile_ctx->fp;
|
||||
|
||||
while (!feof (potfile_ctx->fp))
|
||||
{
|
||||
|
@ -54,10 +54,8 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
char *eff_restore_file = restore_ctx->eff_restore_file;
|
||||
|
||||
// FILE *fp = fopen (eff_restore_file, "rb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL)
|
||||
if (hc_fopen (&fp, eff_restore_file, "rb") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Restore file '%s': %s", eff_restore_file, strerror (errno));
|
||||
@ -67,12 +65,10 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
restore_data_t *rd = restore_ctx->rd;
|
||||
|
||||
// if (fread (rd, sizeof (restore_data_t), 1, fp) != 1)
|
||||
if (hc_fread (rd, sizeof (restore_data_t), 1, &fp) != 1)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Cannot read %s", eff_restore_file);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return -1;
|
||||
@ -84,7 +80,6 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Unusually low number of arguments (argc) within restore file %s", eff_restore_file);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return -1;
|
||||
@ -94,7 +89,6 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Unusually high number of arguments (argc) within restore file %s", eff_restore_file);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return -1;
|
||||
@ -106,12 +100,10 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
for (u32 i = 0; i < rd->argc; i++)
|
||||
{
|
||||
// if (fgets (buf, HCBUFSIZ_LARGE - 1, fp) == NULL)
|
||||
if (hc_fgets (buf, HCBUFSIZ_LARGE - 1, &fp) == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Cannot read %s", eff_restore_file);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return -1;
|
||||
@ -126,7 +118,6 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hcfree (buf);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
if (hc_path_exist (rd->cwd) == false)
|
||||
@ -212,10 +203,8 @@ static int write_restore (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
char *new_restore_file = restore_ctx->new_restore_file;
|
||||
|
||||
// FILE *fp = fopen (new_restore_file, "wb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL)
|
||||
if (hc_fopen (&fp, new_restore_file, "wb") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", new_restore_file, strerror (errno));
|
||||
@ -225,12 +214,10 @@ static int write_restore (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
fp.is_gzip = false;
|
||||
|
||||
// if (setvbuf (fp, NULL, _IONBF, 0))
|
||||
if (setvbuf (fp.f.fp, NULL, _IONBF, 0))
|
||||
if (setvbuf (fp.pfp, NULL, _IONBF, 0))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "setvbuf file '%s': %s", new_restore_file, strerror (errno));
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return -1;
|
||||
@ -240,20 +227,15 @@ static int write_restore (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
for (u32 i = 0; i < rd->argc; i++)
|
||||
{
|
||||
// fprintf (fp, "%s", rd->argv[i]);
|
||||
hc_fprintf (&fp, "%s", rd->argv[i]);
|
||||
|
||||
// fputc ('\n', fp);
|
||||
hc_fputc ('\n', &fp);
|
||||
}
|
||||
|
||||
// fflush (fp);
|
||||
hc_fflush (&fp);
|
||||
|
||||
// fsync (fileno (fp));
|
||||
fsync (hc_fileno (&fp));
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
rd->masks_pos = 0;
|
||||
|
79
src/shared.c
79
src/shared.c
@ -349,16 +349,12 @@ bool hc_path_has_bom (const char *path)
|
||||
{
|
||||
u8 buf[8] = { 0 };
|
||||
|
||||
// FILE *fp = fopen (path, "rb");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL) return false;
|
||||
if (hc_fopen (&fp, path, "rb") == false) return false;
|
||||
|
||||
// const size_t nread = fread (buf, 1, sizeof (buf), fp);
|
||||
const size_t nread = hc_fread (buf, 1, sizeof (buf), &fp);
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
if (nread < 1) return false;
|
||||
@ -624,15 +620,15 @@ bool hc_fopen (HCFILE *fp, const char *path, char *mode)
|
||||
{
|
||||
fclose (fp_tmp);
|
||||
|
||||
if (!(fp->f.gfp = gzopen (path, mode))) return false;
|
||||
if (!(fp->gfp = gzopen (path, mode))) return false;
|
||||
|
||||
fp->is_gzip = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
fp->f.fp = fp_tmp;
|
||||
fp->pfp = fp_tmp;
|
||||
|
||||
rewind (fp->f.fp);
|
||||
rewind (fp->pfp);
|
||||
}
|
||||
|
||||
fp->path = path;
|
||||
@ -648,9 +644,9 @@ size_t hc_fread (void *ptr, size_t size, size_t nmemb, HCFILE *fp)
|
||||
if (fp == NULL) return -1;
|
||||
|
||||
if (fp->is_gzip)
|
||||
n = gzfread (ptr, size, nmemb, fp->f.gfp);
|
||||
n = gzfread (ptr, size, nmemb, fp->gfp);
|
||||
else
|
||||
n = fread (ptr, size, nmemb, fp->f.fp);
|
||||
n = fread (ptr, size, nmemb, fp->pfp);
|
||||
|
||||
return n;
|
||||
}
|
||||
@ -662,9 +658,9 @@ size_t hc_fwrite (void *ptr, size_t size, size_t nmemb, HCFILE *fp)
|
||||
if (fp == NULL) return -1;
|
||||
|
||||
if (fp->is_gzip)
|
||||
n = gzfwrite (ptr, size, nmemb, fp->f.gfp);
|
||||
n = gzfwrite (ptr, size, nmemb, fp->gfp);
|
||||
else
|
||||
n = fwrite (ptr, size, nmemb, fp->f.fp);
|
||||
n = fwrite (ptr, size, nmemb, fp->pfp);
|
||||
|
||||
if (n != nmemb) return -1;
|
||||
|
||||
@ -678,9 +674,9 @@ int hc_fseek (HCFILE *fp, off_t offset, int whence)
|
||||
if (fp == NULL) return -1;
|
||||
|
||||
if (fp->is_gzip)
|
||||
r = gzseek (fp->f.gfp, (z_off_t) offset, whence);
|
||||
r = gzseek (fp->gfp, (z_off_t) offset, whence);
|
||||
else
|
||||
r = fseeko (fp->f.fp, offset, whence);
|
||||
r = fseeko (fp->pfp, offset, whence);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -690,9 +686,9 @@ void hc_rewind (HCFILE *fp)
|
||||
if (fp == NULL) return;
|
||||
|
||||
if (fp->is_gzip)
|
||||
gzrewind (fp->f.gfp);
|
||||
gzrewind (fp->gfp);
|
||||
else
|
||||
rewind (fp->f.fp);
|
||||
rewind (fp->pfp);
|
||||
}
|
||||
|
||||
off_t hc_ftell (HCFILE *fp)
|
||||
@ -702,9 +698,9 @@ off_t hc_ftell (HCFILE *fp)
|
||||
if (fp == NULL) return -1;
|
||||
|
||||
if (fp->is_gzip)
|
||||
n = (off_t) gztell (fp->f.gfp);
|
||||
n = (off_t) gztell (fp->gfp);
|
||||
else
|
||||
n = ftello (fp->f.fp);
|
||||
n = ftello (fp->pfp);
|
||||
|
||||
return n;
|
||||
}
|
||||
@ -716,9 +712,9 @@ int hc_fputc (int c, HCFILE *fp)
|
||||
if (fp == NULL) return -1;
|
||||
|
||||
if (fp->is_gzip)
|
||||
r = gzputc (fp->f.gfp, c);
|
||||
r = gzputc (fp->gfp, c);
|
||||
else
|
||||
r = fputc (c, fp->f.fp);
|
||||
r = fputc (c, fp->pfp);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -730,9 +726,9 @@ int hc_fgetc (HCFILE *fp)
|
||||
if (fp == NULL) return -1;
|
||||
|
||||
if (fp->is_gzip)
|
||||
r = gzgetc (fp->f.gfp);
|
||||
r = gzgetc (fp->gfp);
|
||||
else
|
||||
r = fgetc (fp->f.fp);
|
||||
r = fgetc (fp->pfp);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -744,9 +740,9 @@ char *hc_fgets (char *buf, int len, HCFILE *fp)
|
||||
if (fp == NULL) return NULL;
|
||||
|
||||
if (fp->is_gzip)
|
||||
r = gzgets (fp->f.gfp, buf, len);
|
||||
r = gzgets (fp->gfp, buf, len);
|
||||
else
|
||||
r = fgets (buf, len, fp->f.fp);
|
||||
r = fgets (buf, len, fp->pfp);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -758,9 +754,9 @@ int hc_vfprintf (HCFILE *fp, const char *format, va_list ap)
|
||||
if (fp == NULL) return -1;
|
||||
|
||||
if (fp->is_gzip)
|
||||
r = gzvprintf (fp->f.gfp, format, ap);
|
||||
r = gzvprintf (fp->gfp, format, ap);
|
||||
else
|
||||
r = vfprintf (fp->f.fp, format, ap);
|
||||
r = vfprintf (fp->pfp, format, ap);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -775,9 +771,9 @@ int hc_fprintf (HCFILE *fp, const char *format, ...)
|
||||
va_start (ap, format);
|
||||
|
||||
if (fp->is_gzip)
|
||||
r = gzvprintf (fp->f.gfp, format, ap);
|
||||
r = gzvprintf (fp->gfp, format, ap);
|
||||
else
|
||||
r = vfprintf (fp->f.fp, format, ap);
|
||||
r = vfprintf (fp->pfp, format, ap);
|
||||
|
||||
va_end (ap);
|
||||
|
||||
@ -823,7 +819,7 @@ int hc_fileno (HCFILE *fp)
|
||||
close (rdup);
|
||||
}
|
||||
else
|
||||
r = fileno (fp->f.fp);
|
||||
r = fileno (fp->pfp);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -835,9 +831,9 @@ int hc_feof (HCFILE *fp)
|
||||
if (fp == NULL) return -1;
|
||||
|
||||
if (fp->is_gzip)
|
||||
r = gzeof (fp->f.gfp);
|
||||
r = gzeof (fp->gfp);
|
||||
else
|
||||
r = feof (fp->f.fp);
|
||||
r = feof (fp->pfp);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -847,9 +843,9 @@ void hc_fflush (HCFILE *fp)
|
||||
if (fp == NULL) return;
|
||||
|
||||
if (fp->is_gzip)
|
||||
gzflush (fp->f.gfp, Z_SYNC_FLUSH);
|
||||
gzflush (fp->gfp, Z_SYNC_FLUSH);
|
||||
else
|
||||
fflush (fp->f.fp);
|
||||
fflush (fp->pfp);
|
||||
}
|
||||
|
||||
void hc_fclose (HCFILE *fp)
|
||||
@ -857,11 +853,11 @@ void hc_fclose (HCFILE *fp)
|
||||
if (fp == NULL) return;
|
||||
|
||||
if (fp->is_gzip)
|
||||
gzclose (fp->f.gfp);
|
||||
gzclose (fp->gfp);
|
||||
else
|
||||
fclose (fp->f.fp);
|
||||
fclose (fp->pfp);
|
||||
|
||||
fp->is_gzip = -1;
|
||||
fp->is_gzip = false;
|
||||
|
||||
fp->path = NULL;
|
||||
fp->mode = NULL;
|
||||
@ -876,44 +872,31 @@ bool hc_same_files (char *file1, char *file2)
|
||||
|
||||
int do_check = 0;
|
||||
|
||||
// FILE *fp;
|
||||
HCFILE fp;
|
||||
|
||||
// fp = fopen (file1, "r");
|
||||
|
||||
// if (fp)
|
||||
if (hc_fopen (&fp, file1, "r") == true)
|
||||
{
|
||||
// if (fstat (fileno (fp), &tmpstat_file1))
|
||||
if (fstat (hc_fileno (&fp), &tmpstat_file1))
|
||||
{
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
do_check++;
|
||||
}
|
||||
|
||||
// fp = fopen (file2, "r");
|
||||
|
||||
// if (fp)
|
||||
if (hc_fopen (&fp, file2, "r") == true)
|
||||
{
|
||||
// if (fstat (fileno (fp), &tmpstat_file2))
|
||||
if (fstat (hc_fileno (&fp), &tmpstat_file2))
|
||||
{
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
do_check++;
|
||||
|
16
src/stdout.c
16
src/stdout.c
@ -63,21 +63,16 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
|
||||
HCFILE fp_tmp;
|
||||
fp_tmp.is_gzip = false;
|
||||
fp_tmp.f.fp = stdout;
|
||||
fp_tmp.pfp = stdout;
|
||||
|
||||
// out.fp = stdout;
|
||||
out.fp = &fp_tmp;
|
||||
|
||||
/// PORKODIO
|
||||
|
||||
char *filename = outfile_ctx->filename;
|
||||
|
||||
if (filename)
|
||||
{
|
||||
// FILE *fp = fopen (filename, "ab");
|
||||
HCFILE fp;
|
||||
|
||||
// if (fp == NULL)
|
||||
if (hc_fopen (&fp, filename, "ab") == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno));
|
||||
@ -87,10 +82,8 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
|
||||
fp.is_gzip = false;
|
||||
|
||||
// if (lock_file (fp) == -1)
|
||||
if (lock_file (fp.f.fp) == -1)
|
||||
if (lock_file (fp.pfp) == -1)
|
||||
{
|
||||
// fclose (fp);
|
||||
hc_fclose (&fp);
|
||||
|
||||
event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno));
|
||||
@ -121,7 +114,6 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
// if (filename) fclose (out.fp);
|
||||
if (filename) hc_fclose (out.fp);
|
||||
|
||||
return -1;
|
||||
@ -166,7 +158,6 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
// if (filename) fclose (out.fp);
|
||||
if (filename) hc_fclose (out.fp);
|
||||
|
||||
return -1;
|
||||
@ -237,7 +228,6 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
// if (filename) fclose (out.fp);
|
||||
if (filename) hc_fclose (out.fp);
|
||||
|
||||
return -1;
|
||||
@ -275,7 +265,6 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
// if (filename) fclose (out.fp);
|
||||
if (filename) hc_fclose (out.fp);
|
||||
|
||||
return -1;
|
||||
@ -308,7 +297,6 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
|
||||
out_flush (&out);
|
||||
|
||||
// if (filename) fclose (out.fp);
|
||||
if (filename) hc_fclose (out.fp);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user