From 5f109b5862520e32406f797242c04b52e6e2e4d1 Mon Sep 17 00:00:00 2001 From: Jukka Ojanen Date: Sat, 3 Jul 2021 12:51:37 +0300 Subject: [PATCH] Fix iconv_ctx and iconv_tmp leaks in backend.c --- src/backend.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/backend.c b/src/backend.c index da5aae373..c0a40e748 100644 --- a/src/backend.c +++ b/src/backend.c @@ -4514,7 +4514,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co iconv_t iconv_ctx = NULL; - char *iconv_tmp = NULL; + char iconv_tmp[HCBUFSIZ_TINY] = { 0 }; if (strcmp (user_options->encoding_from, user_options->encoding_to) != 0) { @@ -4523,8 +4523,6 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co iconv_ctx = iconv_open (user_options->encoding_to, user_options->encoding_from); if (iconv_ctx == (iconv_t) -1) return -1; - - iconv_tmp = (char *) hcmalloc (HCBUFSIZ_TINY); } // find higest password length, this is for optimization stuff @@ -5160,6 +5158,11 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co device_param->speed_only_finish = true; } + if (iconv_enabled == true) + { + iconv_close (iconv_ctx); + } + return 0; }