From 701ad7c4418f7d6490222f6ad038709a565511d3 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Wed, 30 Jun 2021 21:01:55 +0200 Subject: [PATCH] Fix segfault in --hash-info by avoid huge stack buffer allocation --- include/outfile.h | 2 +- src/outfile.c | 2 +- src/terminal.c | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/outfile.h b/include/outfile.h index 7201aad42..953f68a71 100644 --- a/include/outfile.h +++ b/include/outfile.h @@ -20,6 +20,6 @@ int outfile_init (hashcat_ctx_t *hashcat_ctx); void outfile_destroy (hashcat_ctx_t *hashcat_ctx); int outfile_write_open (hashcat_ctx_t *hashcat_ctx); void outfile_write_close (hashcat_ctx_t *hashcat_ctx); -int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int out_len, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, const bool print_eol, char tmp_buf[HCBUFSIZ_LARGE]); +int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int out_len, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, const bool print_eol, char *tmp_buf); #endif // _OUTFILE_H diff --git a/src/outfile.c b/src/outfile.c index bc18f4520..26c135657 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -550,7 +550,7 @@ void outfile_write_close (hashcat_ctx_t *hashcat_ctx) hc_fclose (&outfile_ctx->fp); } -int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int out_len, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, const bool print_eol, char tmp_buf[HCBUFSIZ_LARGE]) +int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int out_len, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, const bool print_eol, char *tmp_buf) { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; const user_options_t *user_options = hashcat_ctx->user_options; diff --git a/src/terminal.c b/src/terminal.c index ca9b3d563..644881ce2 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -636,7 +636,7 @@ void hash_info_single (hashcat_ctx_t *hashcat_ctx, user_options_t *user_options) if (need_hexify ((const u8 *) hashconfig->st_pass, strlen (hashconfig->st_pass), user_options->separator, false)) { - char tmp_buf[HCBUFSIZ_LARGE] = { 0 }; + char *tmp_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); int tmp_len = 0; @@ -654,6 +654,8 @@ void hash_info_single (hashcat_ctx_t *hashcat_ctx, user_options_t *user_options) tmp_buf[tmp_len++] = 0; event_log_info (hashcat_ctx, " Example.Pass........: %s", tmp_buf); + + hcfree (tmp_buf); } else {