update all HCFILE vars and related code

This commit is contained in:
Gabriele Gristina
2019-07-02 21:30:35 +02:00
parent 2db6dfcd4e
commit 3d39d2fc91
11 changed files with 94 additions and 117 deletions

View File

@@ -37,18 +37,18 @@ static void debugfile_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_
if (needs_hexify == 1)
{
hc_fprintf (debugfile_ctx->fp, "$HEX[");
hc_fprintf (&debugfile_ctx->fp, "$HEX[");
for (u32 i = 0; i < plain_len; i++)
{
hc_fprintf (debugfile_ctx->fp, "%02x", plain_ptr[i]);
hc_fprintf (&debugfile_ctx->fp, "%02x", plain_ptr[i]);
}
hc_fprintf (debugfile_ctx->fp, "]");
hc_fprintf (&debugfile_ctx->fp, "]");
}
else
{
hc_fwrite ((void *)plain_ptr, plain_len, 1, debugfile_ctx->fp);
hc_fwrite ((void *)plain_ptr, plain_len, 1, &debugfile_ctx->fp);
}
}
@@ -64,19 +64,19 @@ 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)) hc_fputc (':', debugfile_ctx->fp);
if ((debug_mode == 3) || (debug_mode == 4)) hc_fputc (':', &debugfile_ctx->fp);
}
hc_fwrite ((void *)rule_buf, rule_len, 1, debugfile_ctx->fp);
hc_fwrite ((void *)rule_buf, rule_len, 1, &debugfile_ctx->fp);
if (debug_mode == 4)
{
hc_fputc (':', debugfile_ctx->fp);
hc_fputc (':', &debugfile_ctx->fp);
debugfile_format_plain (hashcat_ctx, mod_plain_ptr, mod_plain_len);
}
hc_fwrite (EOL, strlen (EOL), 1, debugfile_ctx->fp);
hc_fwrite (EOL, strlen (EOL), 1, &debugfile_ctx->fp);
}
int debugfile_init (hashcat_ctx_t *hashcat_ctx)
@@ -105,35 +105,29 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx)
debugfile_ctx->filename = user_options->debug_file;
HCFILE fp;
if (debugfile_ctx->filename)
{
if (hc_fopen (&fp, debugfile_ctx->filename, "ab") == false)
if (hc_fopen (&debugfile_ctx->fp, debugfile_ctx->filename, "ab") == false)
{
event_log_error (hashcat_ctx, "Could not open --debug-file file for writing.");
return -1;
}
if (hc_lockfile (&fp) == -1)
if (hc_lockfile (&debugfile_ctx->fp) == -1)
{
hc_fclose (&fp);
hc_fclose (&debugfile_ctx->fp);
event_log_error (hashcat_ctx, "%s: %s", debugfile_ctx->filename, strerror (errno));
return -1;
}
debugfile_ctx->fp = &fp;
}
else
{
fp.is_gzip = false;
fp.pfp = stdout;
fp.fd = fileno (stdout);
debugfile_ctx->fp = &fp;
debugfile_ctx->fp.is_gzip = false;
debugfile_ctx->fp.pfp = stdout;
debugfile_ctx->fp.fd = fileno (stdout);
}
return 0;
@@ -147,7 +141,7 @@ void debugfile_destroy (hashcat_ctx_t *hashcat_ctx)
if (debugfile_ctx->filename)
{
hc_fclose (debugfile_ctx->fp);
hc_fclose (&debugfile_ctx->fp);
}
memset (debugfile_ctx, 0, sizeof (debugfile_ctx_t));