From 9c7b9253e74abf570c20da4d71e7db8bc84f6198 Mon Sep 17 00:00:00 2001 From: Jukka Ojanen Date: Wed, 11 Aug 2021 02:17:21 +0300 Subject: [PATCH] Fix potfile not closed if opened --- src/potfile.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/potfile.c b/src/potfile.c index c6c127fc4..978247afa 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -185,10 +185,13 @@ void potfile_destroy (hashcat_ctx_t *hashcat_ctx) int potfile_read_open (hashcat_ctx_t *hashcat_ctx) { - potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; if (potfile_ctx->enabled == false) return 0; + if (hashconfig->potfile_disable == true) return 0; + if (hc_fopen (&potfile_ctx->fp, potfile_ctx->filename, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", potfile_ctx->filename, strerror (errno)); @@ -201,8 +204,8 @@ int potfile_read_open (hashcat_ctx_t *hashcat_ctx) void potfile_read_close (hashcat_ctx_t *hashcat_ctx) { - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; if (potfile_ctx->enabled == false) return; @@ -215,10 +218,13 @@ void potfile_read_close (hashcat_ctx_t *hashcat_ctx) int potfile_write_open (hashcat_ctx_t *hashcat_ctx) { - potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; if (potfile_ctx->enabled == false) return 0; + if (hashconfig->potfile_disable == true) return 0; + if (hc_fopen (&potfile_ctx->fp, potfile_ctx->filename, "ab") == false) { event_log_error (hashcat_ctx, "%s: %s", potfile_ctx->filename, strerror (errno)); @@ -231,8 +237,8 @@ int potfile_write_open (hashcat_ctx_t *hashcat_ctx) void potfile_write_close (hashcat_ctx_t *hashcat_ctx) { - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; if (potfile_ctx->enabled == false) return;