From dbe60b845b04d55f1580b16f4299b8bcce3c9d98 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Thu, 27 Oct 2016 22:29:57 +0200 Subject: [PATCH] Fix OSX segfault on check_hash() --- src/hashes.c | 6 +++++- src/potfile.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hashes.c b/src/hashes.c index f8ea8fdd0..77082663e 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -231,7 +231,9 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl // hash - char out_buf[HCBUFSIZ_LARGE]; + char *out_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + + if (!out_buf) return; out_buf[0] = 0; @@ -276,6 +278,8 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl const int tmp_len = outfile_write (hashcat_ctx, out_buf, plain_ptr, plain_len, crackpos, NULL, 0, tmp_buf); + free (out_buf); + outfile_write_close (hashcat_ctx); EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len); diff --git a/src/potfile.c b/src/potfile.c index 7b9a1afd5..012293c74 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -256,7 +256,9 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 * if (potfile_ctx->enabled == false) return; - char tmp_buf[HCBUFSIZ_LARGE]; + char *tmp_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + + if (!tmp_buf) return; int tmp_len = 0; @@ -300,6 +302,8 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 * tmp_buf[tmp_len] = 0; fprintf (potfile_ctx->fp, "%s" EOL, tmp_buf); + + free (tmp_buf); } int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)