diff --git a/include/filehandling.h b/include/filehandling.h index b8f70d40c..582599453 100644 --- a/include/filehandling.h +++ b/include/filehandling.h @@ -10,7 +10,7 @@ #include #include -u64 count_lines (hashcat_ctx_t *hashcat_ctx, FILE *fd); +u64 count_lines (FILE *fd); int fgetl (FILE *fp, char *line_buf); diff --git a/include/folder.h b/include/folder.h index 3dde0cace..e41f79f76 100644 --- a/include/folder.h +++ b/include/folder.h @@ -33,7 +33,7 @@ int count_dictionaries (char **dictionary_files); char *first_file_in_directory (const char *path); -char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path); +char **scan_directory (const char *path); int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *install_folder, MAYBE_UNUSED const char *shared_folder); void folder_config_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/memory.h b/include/memory.h index c1193d78c..ba2bd6a94 100644 --- a/include/memory.h +++ b/include/memory.h @@ -12,12 +12,10 @@ #define MSG_ENOMEM "Insufficient memory available" -#define VERIFY_PTR(v) if ((v) == NULL) return -1; - -void *hccalloc (hashcat_ctx_t *hashcat_ctx, const size_t nmemb, const size_t sz); -void *hcmalloc (hashcat_ctx_t *hashcat_ctx, const size_t sz); -void *hcrealloc (hashcat_ctx_t *hashcat_ctx, void *ptr, const size_t oldsz, const size_t addsz); -char *hcstrdup (hashcat_ctx_t *hashcat_ctx, const char *s); +void *hccalloc (const size_t nmemb, const size_t sz); +void *hcmalloc (const size_t sz); +void *hcrealloc (void *ptr, const size_t oldsz, const size_t addsz); +char *hcstrdup (const char *s); void hcfree (void *ptr); #endif // _MEMORY_H diff --git a/src/affinity.c b/src/affinity.c index 8f0ef9107..edd62e86b 100644 --- a/src/affinity.c +++ b/src/affinity.c @@ -57,7 +57,7 @@ int set_cpu_affinity (hashcat_ctx_t *hashcat_ctx) CPU_ZERO (&cpuset); #endif - char *devices = hcstrdup (hashcat_ctx, user_options->cpu_affinity); + char *devices = hcstrdup (user_options->cpu_affinity); char *saveptr = NULL; diff --git a/src/bitmap.c b/src/bitmap.c index 82f65e677..ab7e7fd2b 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -77,14 +77,14 @@ int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) const u32 bitmap_min = user_options->bitmap_min; const u32 bitmap_max = user_options->bitmap_max; - u32 *bitmap_s1_a = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s1_a); - u32 *bitmap_s1_b = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s1_b); - u32 *bitmap_s1_c = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s1_c); - u32 *bitmap_s1_d = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s1_d); - u32 *bitmap_s2_a = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s2_a); - u32 *bitmap_s2_b = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s2_b); - u32 *bitmap_s2_c = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s2_c); - u32 *bitmap_s2_d = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s2_d); + u32 *bitmap_s1_a = (u32 *) hcmalloc ((1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s1_b = (u32 *) hcmalloc ((1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s1_c = (u32 *) hcmalloc ((1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s1_d = (u32 *) hcmalloc ((1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s2_a = (u32 *) hcmalloc ((1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s2_b = (u32 *) hcmalloc ((1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s2_c = (u32 *) hcmalloc ((1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s2_d = (u32 *) hcmalloc ((1u << bitmap_max) * sizeof (u32)); u32 bitmap_bits; u32 bitmap_nums; diff --git a/src/combinator.c b/src/combinator.c index 2e52573ac..a0a3fb271 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -31,7 +31,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) combinator_ctx->enabled = true; - combinator_ctx->scratch_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (combinator_ctx->scratch_buf); + combinator_ctx->scratch_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { diff --git a/src/cpt.c b/src/cpt.c index 84530cde5..021cb72a3 100644 --- a/src/cpt.c +++ b/src/cpt.c @@ -24,7 +24,7 @@ int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx) cpt_ctx->enabled = true; - cpt_ctx->cpt_buf = (cpt_t *) hccalloc (hashcat_ctx, CPT_CACHE, sizeof (cpt_t)); VERIFY_PTR (cpt_ctx->cpt_buf); + cpt_ctx->cpt_buf = (cpt_t *) hccalloc (CPT_CACHE, sizeof (cpt_t)); cpt_ctx->cpt_total = 0; cpt_ctx->cpt_pos = 0; diff --git a/src/cpu_crc32.c b/src/cpu_crc32.c index 1a4b2568f..6618e0ce1 100644 --- a/src/cpu_crc32.c +++ b/src/cpu_crc32.c @@ -92,7 +92,7 @@ int cpu_crc32 (hashcat_ctx_t *hashcat_ctx, const char *filename, u8 keytab[64]) #define MAX_KEY_SIZE (1024 * 1024) - u8 *buf = (u8 *) hcmalloc (hashcat_ctx, MAX_KEY_SIZE + 1); VERIFY_PTR (buf); + u8 *buf = (u8 *) hcmalloc (MAX_KEY_SIZE + 1); size_t nread = fread (buf, sizeof (u8), MAX_KEY_SIZE, fd); diff --git a/src/dictstat.c b/src/dictstat.c index 1b28eb0f0..f4fecd547 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -43,8 +43,8 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx) if (user_options->attack_mode == ATTACK_MODE_BF) return 0; dictstat_ctx->enabled = true; - dictstat_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (dictstat_ctx->filename); - dictstat_ctx->base = (dictstat_t *) hccalloc (hashcat_ctx, MAX_DICTSTAT, sizeof (dictstat_t)); VERIFY_PTR (dictstat_ctx->base); + dictstat_ctx->filename = (char *) hcmalloc (HCBUFSIZ_TINY); + dictstat_ctx->base = (dictstat_t *) hccalloc (MAX_DICTSTAT, sizeof (dictstat_t)); dictstat_ctx->cnt = 0; snprintf (dictstat_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.dictstat", folder_config->profile_dir); diff --git a/src/dispatch.c b/src/dispatch.c index 629357313..a85eab4ca 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -121,7 +121,7 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (buf); + char *buf = (char *) hcmalloc (HCBUFSIZ_LARGE); const u32 attack_kern = user_options_extra->attack_kern; @@ -368,7 +368,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) } } - hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_ctx_t)); VERIFY_PTR (hashcat_ctx_tmp); + hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (sizeof (hashcat_ctx_t)); /* hashcat_ctx_tmp->bitmap_ctx = hashcat_ctx->bitmap_ctx; @@ -398,7 +398,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) memcpy (hashcat_ctx_tmp, hashcat_ctx, sizeof (hashcat_ctx_t)); // yes we actually want to copy these pointers - hashcat_ctx_tmp->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t)); VERIFY_PTR (hashcat_ctx_tmp->wl_data); + hashcat_ctx_tmp->wl_data = (wl_data_t *) hcmalloc (sizeof (wl_data_t)); const int rc_wl_data_init = wl_data_init (hashcat_ctx_tmp); diff --git a/src/filehandling.c b/src/filehandling.c index b2d6a5968..790a3e6d7 100644 --- a/src/filehandling.c +++ b/src/filehandling.c @@ -8,11 +8,11 @@ #include "memory.h" #include "filehandling.h" -u64 count_lines (hashcat_ctx_t *hashcat_ctx, FILE *fd) +u64 count_lines (FILE *fd) { u64 cnt = 0; - char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE + 1); VERIFY_PTR (buf); + char *buf = (char *) hcmalloc (HCBUFSIZ_LARGE + 1); char prev = '\n'; diff --git a/src/folder.c b/src/folder.c index 14c176a79..72eba9230 100644 --- a/src/folder.c +++ b/src/folder.c @@ -173,9 +173,9 @@ char *first_file_in_directory (const char *path) return NULL; } -char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path) +char **scan_directory (const char *path) { - char *tmp_path = hcstrdup (hashcat_ctx, path); + char *tmp_path = hcstrdup (path); size_t tmp_path_len = strlen (tmp_path); @@ -219,7 +219,7 @@ char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path) if ((strcmp (de->d_name, ".") == 0) || (strcmp (de->d_name, "..") == 0)) continue; - char *path_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *path_file = (char *) hcmalloc (HCBUFSIZ_TINY); snprintf (path_file, HCBUFSIZ_TINY - 1, "%s/%s", tmp_path, de->d_name); @@ -233,7 +233,7 @@ char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path) } else { - files = (char **) hcrealloc (hashcat_ctx, files, (num_files + 1) * sizeof (char *), sizeof (char *)); + files = (char **) hcrealloc (files, (num_files + 1) * sizeof (char *), sizeof (char *)); files[num_files] = path_file; @@ -245,14 +245,14 @@ char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path) } else if (errno == ENOTDIR) { - files = (char **) hcrealloc (hashcat_ctx, files, (num_files + 1) * sizeof (char *), sizeof (char *)); + files = (char **) hcrealloc (files, (num_files + 1) * sizeof (char *), sizeof (char *)); - files[num_files] = hcstrdup (hashcat_ctx, path); + files[num_files] = hcstrdup (path); num_files++; } - files = (char **) hcrealloc (hashcat_ctx, files, (num_files + 1) * sizeof (char *), sizeof (char *)); + files = (char **) hcrealloc (files, (num_files + 1) * sizeof (char *), sizeof (char *)); files[num_files] = NULL; @@ -274,7 +274,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * then chdir() back to where we came from so we need to save it first */ - char *cwd = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (cwd); + char *cwd = (char *) hcmalloc (HCBUFSIZ_TINY); if (getcwd (cwd, HCBUFSIZ_TINY - 1) == NULL) { @@ -289,7 +289,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins const size_t exec_path_sz = 1024; - char *exec_path = (char *) hcmalloc (hashcat_ctx, exec_path_sz); VERIFY_PTR (exec_path); + char *exec_path = (char *) hcmalloc (exec_path_sz); const int rc = get_exec_path (exec_path, exec_path_sz); @@ -309,7 +309,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins char *resolved_install_folder = realpath (install_folder, NULL); char *resolved_exec_path = realpath (exec_path, NULL); - if (resolved_install_folder == NULL) resolved_install_folder = hcstrdup (hashcat_ctx, SLASH); + if (resolved_install_folder == NULL) resolved_install_folder = hcstrdup (SLASH); /* This causes invalid error out if install_folder (/usr/local/bin) does not exist @@ -328,7 +328,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins return -1; } - char *install_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (install_dir); + char *install_dir = hcmalloc (HCBUFSIZ_TINY); get_install_dir (install_dir, resolved_exec_path); @@ -347,13 +347,13 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins const char *home_dir = pwp->pw_dir; - profile_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (profile_dir); - session_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (session_dir); + profile_dir = hcmalloc (HCBUFSIZ_TINY); + session_dir = hcmalloc (HCBUFSIZ_TINY); get_profile_dir (profile_dir, home_dir); get_session_dir (session_dir, profile_dir); - shared_dir = hcstrdup (hashcat_ctx, shared_folder); + shared_dir = hcstrdup (shared_folder); hc_mkdir (profile_dir, 0700); hc_mkdir (session_dir, 0700); @@ -370,7 +370,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins #else - char *install_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (install_dir); + char *install_dir = hcmalloc (HCBUFSIZ_TINY); get_install_dir (install_dir, exec_path); @@ -389,13 +389,13 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * The best workaround found so far is to modify the TMP variable (only inside hashcat process) before the runtime is load */ - char *cpath = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (cpath); + char *cpath = (char *) hcmalloc (HCBUFSIZ_TINY); #if defined (_WIN) snprintf (cpath, HCBUFSIZ_TINY - 1, "%s\\OpenCL\\", shared_dir); - char *cpath_real = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (cpath_real); + char *cpath_real = (char *) hcmalloc (HCBUFSIZ_TINY); if (GetFullPathName (cpath, HCBUFSIZ_TINY - 1, cpath_real, NULL) == 0) { @@ -408,7 +408,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins snprintf (cpath, HCBUFSIZ_TINY - 1, "%s/OpenCL/", shared_dir); - char *cpath_real = (char *) hcmalloc (hashcat_ctx, PATH_MAX); VERIFY_PTR (cpath_real); + char *cpath_real = (char *) hcmalloc (PATH_MAX); if (realpath (cpath, cpath_real) == NULL) { @@ -448,7 +448,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * kernel cache, we need to make sure folder exist */ - char *kernels_folder = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (kernels_folder); + char *kernels_folder = (char *) hcmalloc (HCBUFSIZ_TINY); snprintf (kernels_folder, HCBUFSIZ_TINY - 1, "%s/kernels", profile_dir); diff --git a/src/hashcat.c b/src/hashcat.c index 565bba124..b3208d8dd 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -161,9 +161,9 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_AUTOTUNE_STARTING); - thread_param_t *threads_param = (thread_param_t *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (thread_param_t)); VERIFY_PTR (threads_param); + thread_param_t *threads_param = (thread_param_t *) hccalloc (opencl_ctx->devices_cnt, sizeof (thread_param_t)); - hc_thread_t *c_threads = (hc_thread_t *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (hc_thread_t)); VERIFY_PTR (c_threads); + hc_thread_t *c_threads = (hc_thread_t *) hccalloc (opencl_ctx->devices_cnt, sizeof (hc_thread_t)); status_ctx->devices_status = STATUS_AUTOTUNE; @@ -656,7 +656,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) int inner_threads_cnt = 0; - hc_thread_t *inner_threads = (hc_thread_t *) hccalloc (hashcat_ctx, 10, sizeof (hc_thread_t)); VERIFY_PTR (inner_threads); + hc_thread_t *inner_threads = (hc_thread_t *) hccalloc (10, sizeof (hc_thread_t)); status_ctx->shutdown_inner = false; @@ -769,32 +769,32 @@ int hashcat_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct h hashcat_ctx->event = event; - hashcat_ctx->bitmap_ctx = (bitmap_ctx_t *) hcmalloc (hashcat_ctx, sizeof (bitmap_ctx_t)); VERIFY_PTR (hashcat_ctx->bitmap_ctx); - hashcat_ctx->combinator_ctx = (combinator_ctx_t *) hcmalloc (hashcat_ctx, sizeof (combinator_ctx_t)); VERIFY_PTR (hashcat_ctx->combinator_ctx); - hashcat_ctx->cpt_ctx = (cpt_ctx_t *) hcmalloc (hashcat_ctx, sizeof (cpt_ctx_t)); VERIFY_PTR (hashcat_ctx->cpt_ctx); - hashcat_ctx->debugfile_ctx = (debugfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (debugfile_ctx_t)); VERIFY_PTR (hashcat_ctx->debugfile_ctx); - hashcat_ctx->dictstat_ctx = (dictstat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (dictstat_ctx_t)); VERIFY_PTR (hashcat_ctx->dictstat_ctx); - hashcat_ctx->event_ctx = (event_ctx_t *) hcmalloc (hashcat_ctx, sizeof (event_ctx_t)); VERIFY_PTR (hashcat_ctx->event_ctx); - hashcat_ctx->folder_config = (folder_config_t *) hcmalloc (hashcat_ctx, sizeof (folder_config_t)); VERIFY_PTR (hashcat_ctx->folder_config); - hashcat_ctx->hashcat_user = (hashcat_user_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_user_t)); VERIFY_PTR (hashcat_ctx->hashcat_user); - hashcat_ctx->hashconfig = (hashconfig_t *) hcmalloc (hashcat_ctx, sizeof (hashconfig_t)); VERIFY_PTR (hashcat_ctx->hashconfig); - hashcat_ctx->hashes = (hashes_t *) hcmalloc (hashcat_ctx, sizeof (hashes_t)); VERIFY_PTR (hashcat_ctx->hashes); - hashcat_ctx->hwmon_ctx = (hwmon_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hwmon_ctx_t)); VERIFY_PTR (hashcat_ctx->hwmon_ctx); - hashcat_ctx->induct_ctx = (induct_ctx_t *) hcmalloc (hashcat_ctx, sizeof (induct_ctx_t)); VERIFY_PTR (hashcat_ctx->induct_ctx); - hashcat_ctx->logfile_ctx = (logfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (logfile_ctx_t)); VERIFY_PTR (hashcat_ctx->logfile_ctx); - hashcat_ctx->loopback_ctx = (loopback_ctx_t *) hcmalloc (hashcat_ctx, sizeof (loopback_ctx_t)); VERIFY_PTR (hashcat_ctx->loopback_ctx); - hashcat_ctx->mask_ctx = (mask_ctx_t *) hcmalloc (hashcat_ctx, sizeof (mask_ctx_t)); VERIFY_PTR (hashcat_ctx->mask_ctx); - hashcat_ctx->opencl_ctx = (opencl_ctx_t *) hcmalloc (hashcat_ctx, sizeof (opencl_ctx_t)); VERIFY_PTR (hashcat_ctx->opencl_ctx); - hashcat_ctx->outcheck_ctx = (outcheck_ctx_t *) hcmalloc (hashcat_ctx, sizeof (outcheck_ctx_t)); VERIFY_PTR (hashcat_ctx->outcheck_ctx); - hashcat_ctx->outfile_ctx = (outfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (outfile_ctx_t)); VERIFY_PTR (hashcat_ctx->outfile_ctx); - hashcat_ctx->potfile_ctx = (potfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (potfile_ctx_t)); VERIFY_PTR (hashcat_ctx->potfile_ctx); - hashcat_ctx->restore_ctx = (restore_ctx_t *) hcmalloc (hashcat_ctx, sizeof (restore_ctx_t)); VERIFY_PTR (hashcat_ctx->restore_ctx); - hashcat_ctx->status_ctx = (status_ctx_t *) hcmalloc (hashcat_ctx, sizeof (status_ctx_t)); VERIFY_PTR (hashcat_ctx->status_ctx); - hashcat_ctx->straight_ctx = (straight_ctx_t *) hcmalloc (hashcat_ctx, sizeof (straight_ctx_t)); VERIFY_PTR (hashcat_ctx->straight_ctx); - hashcat_ctx->tuning_db = (tuning_db_t *) hcmalloc (hashcat_ctx, sizeof (tuning_db_t)); VERIFY_PTR (hashcat_ctx->tuning_db); - hashcat_ctx->user_options_extra = (user_options_extra_t *) hcmalloc (hashcat_ctx, sizeof (user_options_extra_t)); VERIFY_PTR (hashcat_ctx->user_options_extra); - hashcat_ctx->user_options = (user_options_t *) hcmalloc (hashcat_ctx, sizeof (user_options_t)); VERIFY_PTR (hashcat_ctx->user_options); - hashcat_ctx->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t)); VERIFY_PTR (hashcat_ctx->wl_data); + hashcat_ctx->bitmap_ctx = (bitmap_ctx_t *) hcmalloc (sizeof (bitmap_ctx_t)); + hashcat_ctx->combinator_ctx = (combinator_ctx_t *) hcmalloc (sizeof (combinator_ctx_t)); + hashcat_ctx->cpt_ctx = (cpt_ctx_t *) hcmalloc (sizeof (cpt_ctx_t)); + hashcat_ctx->debugfile_ctx = (debugfile_ctx_t *) hcmalloc (sizeof (debugfile_ctx_t)); + hashcat_ctx->dictstat_ctx = (dictstat_ctx_t *) hcmalloc (sizeof (dictstat_ctx_t)); + hashcat_ctx->event_ctx = (event_ctx_t *) hcmalloc (sizeof (event_ctx_t)); + hashcat_ctx->folder_config = (folder_config_t *) hcmalloc (sizeof (folder_config_t)); + hashcat_ctx->hashcat_user = (hashcat_user_t *) hcmalloc (sizeof (hashcat_user_t)); + hashcat_ctx->hashconfig = (hashconfig_t *) hcmalloc (sizeof (hashconfig_t)); + hashcat_ctx->hashes = (hashes_t *) hcmalloc (sizeof (hashes_t)); + hashcat_ctx->hwmon_ctx = (hwmon_ctx_t *) hcmalloc (sizeof (hwmon_ctx_t)); + hashcat_ctx->induct_ctx = (induct_ctx_t *) hcmalloc (sizeof (induct_ctx_t)); + hashcat_ctx->logfile_ctx = (logfile_ctx_t *) hcmalloc (sizeof (logfile_ctx_t)); + hashcat_ctx->loopback_ctx = (loopback_ctx_t *) hcmalloc (sizeof (loopback_ctx_t)); + hashcat_ctx->mask_ctx = (mask_ctx_t *) hcmalloc (sizeof (mask_ctx_t)); + hashcat_ctx->opencl_ctx = (opencl_ctx_t *) hcmalloc (sizeof (opencl_ctx_t)); + hashcat_ctx->outcheck_ctx = (outcheck_ctx_t *) hcmalloc (sizeof (outcheck_ctx_t)); + hashcat_ctx->outfile_ctx = (outfile_ctx_t *) hcmalloc (sizeof (outfile_ctx_t)); + hashcat_ctx->potfile_ctx = (potfile_ctx_t *) hcmalloc (sizeof (potfile_ctx_t)); + hashcat_ctx->restore_ctx = (restore_ctx_t *) hcmalloc (sizeof (restore_ctx_t)); + hashcat_ctx->status_ctx = (status_ctx_t *) hcmalloc (sizeof (status_ctx_t)); + hashcat_ctx->straight_ctx = (straight_ctx_t *) hcmalloc (sizeof (straight_ctx_t)); + hashcat_ctx->tuning_db = (tuning_db_t *) hcmalloc (sizeof (tuning_db_t)); + hashcat_ctx->user_options_extra = (user_options_extra_t *) hcmalloc (sizeof (user_options_extra_t)); + hashcat_ctx->user_options = (user_options_t *) hcmalloc (sizeof (user_options_t)); + hashcat_ctx->wl_data = (wl_data_t *) hcmalloc (sizeof (wl_data_t)); return 0; } diff --git a/src/hashes.c b/src/hashes.c index 2a12725e3..878703da3 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -153,7 +153,7 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) } - u8 *out_buf = (u8 *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (out_buf); + u8 *out_buf = (u8 *) hcmalloc (HCBUFSIZ_LARGE); for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) { @@ -341,7 +341,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (num_cracked) { - plain_t *cracked = (plain_t *) hccalloc (hashcat_ctx, num_cracked, sizeof (plain_t)); VERIFY_PTR (cracked); + plain_t *cracked = (plain_t *) hccalloc (num_cracked, sizeof (plain_t)); CL_err = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_plain_bufs, CL_TRUE, 0, num_cracked * sizeof (plain_t), cracked, 0, NULL, NULL); @@ -508,7 +508,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) EVENT_DATA (EVENT_HASHLIST_COUNT_LINES_PRE, hashfile, strlen (hashfile)); - hashes_avail = count_lines (hashcat_ctx, fp); + hashes_avail = count_lines (fp); EVENT_DATA (EVENT_HASHLIST_COUNT_LINES_POST, hashfile, strlen (hashfile)); @@ -558,9 +558,9 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) salt_t *salts_buf = NULL; void *esalts_buf = NULL; - hashes_buf = (hash_t *) hccalloc (hashcat_ctx, hashes_avail, sizeof (hash_t)); VERIFY_PTR (hashes_buf); + hashes_buf = (hash_t *) hccalloc (hashes_avail, sizeof (hash_t)); - digests_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->dgst_size); VERIFY_PTR (digests_buf); + digests_buf = (void *) hccalloc (hashes_avail, hashconfig->dgst_size); if ((user_options->username == true) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) { @@ -568,34 +568,34 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) for (hash_pos = 0; hash_pos < hashes_avail; hash_pos++) { - hashinfo_t *hash_info = (hashinfo_t *) hcmalloc (hashcat_ctx, sizeof (hashinfo_t)); VERIFY_PTR (hash_info); + hashinfo_t *hash_info = (hashinfo_t *) hcmalloc (sizeof (hashinfo_t)); hashes_buf[hash_pos].hash_info = hash_info; if (user_options->username == true) { - hash_info->user = (user_t*) hcmalloc (hashcat_ctx, sizeof (user_t)); VERIFY_PTR (hash_info->user); + hash_info->user = (user_t*) hcmalloc (sizeof (user_t)); } if (user_options->benchmark == true) { - hash_info->orighash = (char *) hcmalloc (hashcat_ctx, 256); VERIFY_PTR (hash_info->orighash); + hash_info->orighash = (char *) hcmalloc (256); } } } if (hashconfig->is_salted) { - salts_buf = (salt_t *) hccalloc (hashcat_ctx, hashes_avail, sizeof (salt_t)); VERIFY_PTR (salts_buf); + salts_buf = (salt_t *) hccalloc (hashes_avail, sizeof (salt_t)); if (hashconfig->esalt_size) { - esalts_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->esalt_size); VERIFY_PTR (esalts_buf); + esalts_buf = (void *) hccalloc (hashes_avail, hashconfig->esalt_size); } } else { - salts_buf = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t)); VERIFY_PTR (salts_buf); + salts_buf = (salt_t *) hccalloc (1, sizeof (salt_t)); } for (u32 hash_pos = 0; hash_pos < hashes_avail; hash_pos++) @@ -677,7 +677,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info; - hash_info_tmp->orighash = hcstrdup (hashcat_ctx, hash_buf); + hash_info_tmp->orighash = hcstrdup (hash_buf); } if (hashconfig->is_salted) @@ -718,7 +718,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) return -1; } - char *in = (char *) hcmalloc (hashcat_ctx, sizeof (hccap_t)); VERIFY_PTR (in); + char *in = (char *) hcmalloc (sizeof (hccap_t)); while (!feof (fp)) { @@ -819,7 +819,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) u32 line_num = 0; - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); + char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); time_t prev = 0; time_t now = 0; @@ -865,17 +865,17 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) user_t **user = &hashes_buf[hashes_cnt].hash_info->user; - *user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); VERIFY_PTR (*user); + *user = (user_t *) hcmalloc (sizeof (user_t)); user_t *user_ptr = *user; if (user_buf != NULL) { - user_ptr->user_name = hcstrdup (hashcat_ctx, user_buf); + user_ptr->user_name = hcstrdup (user_buf); } else { - user_ptr->user_name = hcstrdup (hashcat_ctx, ""); + user_ptr->user_name = hcstrdup (""); } user_ptr->user_len = user_len; @@ -885,7 +885,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info; - hash_info_tmp->orighash = hcstrdup (hashcat_ctx, hash_buf); + hash_info_tmp->orighash = hcstrdup (hash_buf); } if (hashconfig->is_salted) @@ -1050,22 +1050,22 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) * Now generate all the buffers required for later */ - void *digests_buf_new = (void *) hccalloc (hashcat_ctx, hashes_cnt, hashconfig->dgst_size); VERIFY_PTR (digests_buf_new); + void *digests_buf_new = (void *) hccalloc (hashes_cnt, hashconfig->dgst_size); salt_t *salts_buf_new = NULL; void *esalts_buf_new = NULL; if (hashconfig->is_salted) { - salts_buf_new = (salt_t *) hccalloc (hashcat_ctx, hashes_cnt, sizeof (salt_t)); VERIFY_PTR (salts_buf_new); + salts_buf_new = (salt_t *) hccalloc (hashes_cnt, sizeof (salt_t)); } else { - salts_buf_new = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t)); VERIFY_PTR (salts_buf_new); + salts_buf_new = (salt_t *) hccalloc (1, sizeof (salt_t)); } if (hashconfig->esalt_size) { - esalts_buf_new = (void *) hccalloc (hashcat_ctx, hashes_cnt, hashconfig->esalt_size); VERIFY_PTR (esalts_buf_new); + esalts_buf_new = (void *) hccalloc (hashes_cnt, hashconfig->esalt_size); } EVENT (EVENT_HASHLIST_SORT_SALT_PRE); @@ -1073,8 +1073,8 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) u32 digests_cnt = hashes_cnt; u32 digests_done = 0; - u32 *digests_shown = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); VERIFY_PTR (digests_shown); - u32 *digests_shown_tmp = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); VERIFY_PTR (digests_shown_tmp); + u32 *digests_shown = (u32 *) hccalloc (digests_cnt, sizeof (u32)); + u32 *digests_shown_tmp = (u32 *) hccalloc (digests_cnt, sizeof (u32)); u32 salts_cnt = 0; u32 salts_done = 0; @@ -1083,7 +1083,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) if ((user_options->username == true) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) { - hash_info = (hashinfo_t **) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t *)); VERIFY_PTR (hash_info); + hash_info = (hashinfo_t **) hccalloc (hashes_cnt, sizeof (hashinfo_t *)); if (user_options->username == true) { @@ -1091,14 +1091,14 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) for (user_pos = 0; user_pos < hashes_cnt; user_pos++) { - hash_info[user_pos] = (hashinfo_t *) hcmalloc (hashcat_ctx, sizeof (hashinfo_t)); VERIFY_PTR (hash_info[user_pos]); + hash_info[user_pos] = (hashinfo_t *) hcmalloc (sizeof (hashinfo_t)); - hash_info[user_pos]->user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); VERIFY_PTR (hash_info[user_pos]->user); + hash_info[user_pos]->user = (user_t *) hcmalloc (sizeof (user_t)); } } } - u32 *salts_shown = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); VERIFY_PTR (salts_shown); + u32 *salts_shown = (u32 *) hccalloc (digests_cnt, sizeof (u32)); salt_t *salt_buf; @@ -1331,13 +1331,13 @@ int hashes_init_stage4 (hashcat_ctx_t *hashcat_ctx) // starting from here, we should allocate some scratch buffer for later use - u8 *out_buf = (u8 *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (out_buf); + u8 *out_buf = (u8 *) hcmalloc (HCBUFSIZ_LARGE); hashes->out_buf = out_buf; // we need two buffers in parallel - u8 *tmp_buf = (u8 *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (tmp_buf); + u8 *tmp_buf = (u8 *) hcmalloc (HCBUFSIZ_LARGE); hashes->tmp_buf = tmp_buf; diff --git a/src/hlfmt.c b/src/hlfmt.c index 835092eda..d83f85999 100644 --- a/src/hlfmt.c +++ b/src/hlfmt.c @@ -342,11 +342,11 @@ u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, FILE *fp, u32 max_check) if (hashconfig->hash_mode == 5300) return HLFMT_HASHCAT; if (hashconfig->hash_mode == 5400) return HLFMT_HASHCAT; - u32 *formats_cnt = (u32 *) hccalloc (hashcat_ctx, HLFMTS_CNT, sizeof (u32)); VERIFY_PTR (formats_cnt); + u32 *formats_cnt = (u32 *) hccalloc (HLFMTS_CNT, sizeof (u32)); u32 num_check = 0; - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); + char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); while (!feof (fp)) { diff --git a/src/hwmon.c b/src/hwmon.c index b8785b599..a708932b2 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -22,7 +22,7 @@ static int sysfs_init (hashcat_ctx_t *hashcat_ctx) memset (sysfs, 0, sizeof (SYSFS_PTR)); - char *path = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *path = hcmalloc (HCBUFSIZ_TINY); snprintf (path, HCBUFSIZ_TINY - 1, "%s", SYS_BUS_PCI_DEVICES); @@ -55,7 +55,7 @@ static char *hm_SYSFS_get_syspath_device (hashcat_ctx_t *hashcat_ctx, const int hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - char *syspath = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *syspath = hcmalloc (HCBUFSIZ_TINY); snprintf (syspath, HCBUFSIZ_TINY - 1, "%s/0000:%02x:%02x.%01x", SYS_BUS_PCI_DEVICES, device_param->pcie_bus, device_param->pcie_device, device_param->pcie_function); @@ -73,7 +73,7 @@ static char *hm_SYSFS_get_syspath_hwmon (hashcat_ctx_t *hashcat_ctx, const int d return NULL; } - char *hwmon = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *hwmon = hcmalloc (HCBUFSIZ_TINY); snprintf (hwmon, HCBUFSIZ_TINY - 1, "%s/hwmon", syspath); @@ -101,8 +101,8 @@ static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int if (syspath == NULL) return -1; - char *path_cur = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); - char *path_max = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *path_cur = hcmalloc (HCBUFSIZ_TINY); + char *path_max = hcmalloc (HCBUFSIZ_TINY); snprintf (path_cur, HCBUFSIZ_TINY - 1, "%s/pwm1", syspath); snprintf (path_max, HCBUFSIZ_TINY - 1, "%s/pwm1_max", syspath); @@ -174,7 +174,7 @@ static int hm_SYSFS_set_fan_control (hashcat_ctx_t *hashcat_ctx, const int devic if (syspath == NULL) return -1; - char *path = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *path = hcmalloc (HCBUFSIZ_TINY); snprintf (path, HCBUFSIZ_TINY - 1, "%s/pwm1_enable", syspath); @@ -204,8 +204,8 @@ static int hm_SYSFS_set_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int if (syspath == NULL) return -1; - char *path = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); - char *path_max = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *path = hcmalloc (HCBUFSIZ_TINY); + char *path_max = hcmalloc (HCBUFSIZ_TINY); snprintf (path, HCBUFSIZ_TINY - 1, "%s/pwm1", syspath); snprintf (path_max, HCBUFSIZ_TINY - 1, "%s/pwm1_max", syspath); @@ -266,7 +266,7 @@ static int hm_SYSFS_get_temperature_current (hashcat_ctx_t *hashcat_ctx, const i if (syspath == NULL) return -1; - char *path = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *path = hcmalloc (HCBUFSIZ_TINY); snprintf (path, HCBUFSIZ_TINY - 1, "%s/temp1_input", syspath); @@ -305,7 +305,7 @@ static int hm_SYSFS_get_pp_dpm_sclk (hashcat_ctx_t *hashcat_ctx, const int devic if (syspath == NULL) return -1; - char *path = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *path = hcmalloc (HCBUFSIZ_TINY); snprintf (path, HCBUFSIZ_TINY - 1, "%s/pp_dpm_sclk", syspath); @@ -358,7 +358,7 @@ static int hm_SYSFS_get_pp_dpm_mclk (hashcat_ctx_t *hashcat_ctx, const int devic if (syspath == NULL) return -1; - char *path = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *path = hcmalloc (HCBUFSIZ_TINY); snprintf (path, HCBUFSIZ_TINY - 1, "%s/pp_dpm_mclk", syspath); @@ -411,7 +411,7 @@ static int hm_SYSFS_get_pp_dpm_pcie (hashcat_ctx_t *hashcat_ctx, const int devic if (syspath == NULL) return -1; - char *path = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *path = hcmalloc (HCBUFSIZ_TINY); snprintf (path, HCBUFSIZ_TINY - 1, "%s/pp_dpm_pcie", syspath); @@ -465,7 +465,7 @@ static int hm_SYSFS_set_power_dpm_force_performance_level (hashcat_ctx_t *hashca if (syspath == NULL) return -1; - char *path = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *path = hcmalloc (HCBUFSIZ_TINY); snprintf (path, HCBUFSIZ_TINY - 1, "%s/power_dpm_force_performance_level", syspath); @@ -508,7 +508,7 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx) DWORD Type = REG_SZ; - char *Buffer = (char *) hcmalloc (hashcat_ctx, BufferSize + 1); VERIFY_PTR (Buffer); + char *Buffer = (char *) hcmalloc (BufferSize + 1); HKEY hKey = 0; @@ -2418,7 +2418,7 @@ static void hm_sort_adl_adapters_by_busid_devid (u32 *valid_adl_device_list, int } } -static u32 *hm_get_list_valid_adl_adapters (hashcat_ctx_t *hashcat_ctx, int iNumberAdapters, int *num_adl_adapters, LPAdapterInfo lpAdapterInfo) +static u32 *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_adapters, LPAdapterInfo lpAdapterInfo) { *num_adl_adapters = 0; @@ -2457,14 +2457,14 @@ static u32 *hm_get_list_valid_adl_adapters (hashcat_ctx_t *hashcat_ctx, int iNum // add it to the list - adl_adapters = (u32 *) hcrealloc (hashcat_ctx, adl_adapters, (*num_adl_adapters) * sizeof (int), sizeof (int)); // need check + adl_adapters = (u32 *) hcrealloc (adl_adapters, (*num_adl_adapters) * sizeof (int), sizeof (int)); // need check adl_adapters[*num_adl_adapters] = i; // rest is just bookkeeping - bus_numbers = (int*) hcrealloc (hashcat_ctx, bus_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); // need check - device_numbers = (int*) hcrealloc (hashcat_ctx, device_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); // need check + bus_numbers = (int*) hcrealloc (bus_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); // need check + device_numbers = (int*) hcrealloc (device_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); // need check bus_numbers[*num_adl_adapters] = info.iBusNumber; device_numbers[*num_adl_adapters] = info.iDeviceNumber; @@ -3303,23 +3303,23 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->version == true) return 0; if (user_options->gpu_temp_disable == true) return 0; - hwmon_ctx->hm_device = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); VERIFY_PTR (hwmon_ctx->hm_device); + hwmon_ctx->hm_device = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); /** * Initialize shared libraries */ - ADL_PTR *adl = (ADL_PTR *) hcmalloc (hashcat_ctx, sizeof (ADL_PTR)); - NVAPI_PTR *nvapi = (NVAPI_PTR *) hcmalloc (hashcat_ctx, sizeof (NVAPI_PTR)); - NVML_PTR *nvml = (NVML_PTR *) hcmalloc (hashcat_ctx, sizeof (NVML_PTR)); - XNVCTRL_PTR *xnvctrl = (XNVCTRL_PTR *) hcmalloc (hashcat_ctx, sizeof (XNVCTRL_PTR)); - SYSFS_PTR *sysfs = (SYSFS_PTR *) hcmalloc (hashcat_ctx, sizeof (SYSFS_PTR)); + ADL_PTR *adl = (ADL_PTR *) hcmalloc (sizeof (ADL_PTR)); + NVAPI_PTR *nvapi = (NVAPI_PTR *) hcmalloc (sizeof (NVAPI_PTR)); + NVML_PTR *nvml = (NVML_PTR *) hcmalloc (sizeof (NVML_PTR)); + XNVCTRL_PTR *xnvctrl = (XNVCTRL_PTR *) hcmalloc (sizeof (XNVCTRL_PTR)); + SYSFS_PTR *sysfs = (SYSFS_PTR *) hcmalloc (sizeof (SYSFS_PTR)); - hm_attrs_t *hm_adapters_adl = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); VERIFY_PTR (hm_adapters_adl); - hm_attrs_t *hm_adapters_nvapi = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); VERIFY_PTR (hm_adapters_nvapi); - hm_attrs_t *hm_adapters_nvml = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); VERIFY_PTR (hm_adapters_nvml); - hm_attrs_t *hm_adapters_xnvctrl = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); VERIFY_PTR (hm_adapters_xnvctrl); - hm_attrs_t *hm_adapters_sysfs = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); VERIFY_PTR (hm_adapters_sysfs); + hm_attrs_t *hm_adapters_adl = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_nvapi = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_nvml = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_xnvctrl = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_sysfs = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); if (opencl_ctx->need_nvml == true) { @@ -3394,7 +3394,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) { if (hm_NVML_nvmlInit (hashcat_ctx) == 0) { - HM_ADAPTER_NVML *nvmlGPUHandle = (HM_ADAPTER_NVML *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (HM_ADAPTER_NVML)); VERIFY_PTR (nvmlGPUHandle); + HM_ADAPTER_NVML *nvmlGPUHandle = (HM_ADAPTER_NVML *) hccalloc (DEVICES_MAX, sizeof (HM_ADAPTER_NVML)); int tmp_in = hm_get_adapter_index_nvml (hashcat_ctx, nvmlGPUHandle); @@ -3419,7 +3419,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) { if (hm_NvAPI_Initialize (hashcat_ctx) == 0) { - HM_ADAPTER_NVAPI *nvGPUHandle = (HM_ADAPTER_NVAPI *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (HM_ADAPTER_NVAPI)); VERIFY_PTR (nvGPUHandle); + HM_ADAPTER_NVAPI *nvGPUHandle = (HM_ADAPTER_NVAPI *) hccalloc (DEVICES_MAX, sizeof (HM_ADAPTER_NVAPI)); int tmp_in = hm_get_adapter_index_nvapi (hashcat_ctx, nvGPUHandle); @@ -3467,7 +3467,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) // adapter info - LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) hccalloc (hashcat_ctx, hm_adapters_num, sizeof (AdapterInfo)); VERIFY_PTR (lpAdapterInfo); + LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) hccalloc (hm_adapters_num, sizeof (AdapterInfo)); const int rc_adapter_info_adl = hm_get_adapter_info_adl (hashcat_ctx, lpAdapterInfo, hm_adapters_num * sizeof (AdapterInfo)); @@ -3477,7 +3477,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) int num_adl_adapters = 0; - u32 *valid_adl_device_list = hm_get_list_valid_adl_adapters (hashcat_ctx, hm_adapters_num, &num_adl_adapters, lpAdapterInfo); + u32 *valid_adl_device_list = hm_get_list_valid_adl_adapters (hm_adapters_num, &num_adl_adapters, lpAdapterInfo); if (num_adl_adapters > 0) { @@ -3532,11 +3532,11 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) * save buffer required for later restores */ - hwmon_ctx->od_clock_mem_status = (ADLOD6MemClockState *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (ADLOD6MemClockState)); VERIFY_PTR (hwmon_ctx->od_clock_mem_status); + hwmon_ctx->od_clock_mem_status = (ADLOD6MemClockState *) hccalloc (opencl_ctx->devices_cnt, sizeof (ADLOD6MemClockState)); - hwmon_ctx->od_power_control_status = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); VERIFY_PTR (hwmon_ctx->od_power_control_status); + hwmon_ctx->od_power_control_status = (int *) hccalloc (opencl_ctx->devices_cnt, sizeof (int)); - hwmon_ctx->nvml_power_limit = (unsigned int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (unsigned int)); VERIFY_PTR (hwmon_ctx->nvml_power_limit); + hwmon_ctx->nvml_power_limit = (unsigned int *) hccalloc (opencl_ctx->devices_cnt, sizeof (unsigned int)); /** * HM devices: copy @@ -3713,7 +3713,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) event_log_error (hashcat_ctx, "The custom profile seems to have too low maximum memory clock values. You therefore may not reach full performance"); } - ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) hccalloc (hashcat_ctx, 1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); VERIFY_PTR (performance_state); + ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) hccalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); performance_state->iNumberOfPerformanceLevels = 2; @@ -3976,7 +3976,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) // clocks - ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) hccalloc (hashcat_ctx, 1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); + ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) hccalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); performance_state->iNumberOfPerformanceLevels = 2; diff --git a/src/induct.c b/src/induct.c index 1bee34110..2ef431f7a 100644 --- a/src/induct.c +++ b/src/induct.c @@ -47,7 +47,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->induction_dir == NULL) { - char *root_directory = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (root_directory); + char *root_directory = (char *) hcmalloc (HCBUFSIZ_TINY); snprintf (root_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", folder_config->session_dir, user_options->session, INDUCT_DIR); @@ -59,7 +59,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) } else if (errno == ENOTEMPTY) { - char *root_directory_mv = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (root_directory_mv); + char *root_directory_mv = (char *) hcmalloc (HCBUFSIZ_TINY); snprintf (root_directory_mv, HCBUFSIZ_TINY - 1, "%s/%s.induct.%d", folder_config->session_dir, user_options->session, (int) time (NULL)); @@ -89,7 +89,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - induct_ctx->root_directory = hcstrdup (hashcat_ctx, user_options->induction_dir); + induct_ctx->root_directory = hcstrdup (user_options->induction_dir); } return 0; @@ -101,7 +101,7 @@ void induct_ctx_scan (hashcat_ctx_t *hashcat_ctx) if (induct_ctx->enabled == false) return; - induct_ctx->induction_dictionaries = scan_directory (hashcat_ctx, induct_ctx->root_directory); + induct_ctx->induction_dictionaries = scan_directory (induct_ctx->root_directory); induct_ctx->induction_dictionaries_cnt = count_dictionaries (induct_ctx->induction_dictionaries); diff --git a/src/interface.c b/src/interface.c index 2ef58ee10..3dfcf9ad0 100644 --- a/src/interface.c +++ b/src/interface.c @@ -10326,7 +10326,7 @@ int sip_auth_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U // work with a temporary copy of input_buf (s.t. we can manipulate it directly) // why? should be fine to use original buffer - //u8 *temp_input_buf = (u8 *) hcmalloc (hashcat_ctx, input_len + 1); + //u8 *temp_input_buf = (u8 *) hcmalloc (input_len + 1); //memcpy (temp_input_buf, input_buf, input_len); // URI_server: @@ -15023,9 +15023,9 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le const u32 ckey_len = bitcoin_wallet->ckey_len; const u32 public_key_len = bitcoin_wallet->public_key_len; - char *cry_master_buf = (char *) hcmalloc (hashcat_ctx, (cry_master_len * 2) + 1); VERIFY_PTR (cry_master_buf); - char *ckey_buf = (char *) hcmalloc (hashcat_ctx, (ckey_len * 2) + 1); VERIFY_PTR (ckey_buf); - char *public_key_buf = (char *) hcmalloc (hashcat_ctx, (public_key_len * 2) + 1); VERIFY_PTR (public_key_buf); + char *cry_master_buf = (char *) hcmalloc ((cry_master_len * 2) + 1); + char *ckey_buf = (char *) hcmalloc ((ckey_len * 2) + 1); + char *public_key_buf = (char *) hcmalloc ((public_key_len * 2) + 1); for (u32 i = 0, j = 0; i < cry_master_len; i += 1, j += 2) { @@ -15082,7 +15082,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le const u32 data_len = seven_zip->data_len; - char *data_buf = (char *) hcmalloc (hashcat_ctx, (data_len * 2) + 1); VERIFY_PTR (data_buf); + char *data_buf = (char *) hcmalloc ((data_len * 2) + 1); for (u32 i = 0, j = 0; i < data_len; i += 1, j += 2) { @@ -20077,7 +20077,7 @@ int hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx) u32 *keyfile_buf = ((tc_t *) esalts_buf)->keyfile_buf; - char *keyfiles = hcstrdup (hashcat_ctx, tcvc_keyfiles); + char *keyfiles = hcstrdup (tcvc_keyfiles); char *saveptr = NULL; diff --git a/src/logfile.c b/src/logfile.c index c8d7b9bd2..b3fd662b3 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -83,12 +83,12 @@ int logfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->logfile_disable == true) return 0; - logfile_ctx->logfile = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (logfile_ctx->logfile); + logfile_ctx->logfile = (char *) hcmalloc (HCBUFSIZ_TINY); snprintf (logfile_ctx->logfile, HCBUFSIZ_TINY - 1, "%s/%s.log", folder_config->session_dir, user_options->session); - logfile_ctx->subid = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (logfile_ctx->subid); - logfile_ctx->topid = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (logfile_ctx->topid); + logfile_ctx->subid = (char *) hcmalloc (HCBUFSIZ_TINY); + logfile_ctx->topid = (char *) hcmalloc (HCBUFSIZ_TINY); logfile_ctx->enabled = true; diff --git a/src/loopback.c b/src/loopback.c index 0f9812f7c..6a17d4f28 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -72,7 +72,7 @@ int loopback_init (hashcat_ctx_t *hashcat_ctx) loopback_ctx->enabled = true; loopback_ctx->fp = NULL; - loopback_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (loopback_ctx->filename); + loopback_ctx->filename = (char *) hcmalloc (HCBUFSIZ_TINY); return 0; } diff --git a/src/main.c b/src/main.c index baedfd9b6..9f5d6e3f3 100644 --- a/src/main.c +++ b/src/main.c @@ -161,7 +161,7 @@ static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA hashcat_user->outer_threads_cnt = 0; - hashcat_user->outer_threads = (hc_thread_t *) hccalloc (hashcat_ctx, 2, sizeof (hc_thread_t)); if (hashcat_user->outer_threads == NULL) return; + hashcat_user->outer_threads = (hc_thread_t *) hccalloc (2, sizeof (hc_thread_t)); if (hashcat_user->outer_threads == NULL) return; status_ctx->shutdown_outer = false; @@ -839,7 +839,7 @@ int main (int argc, char **argv) // hashcat main context - hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t)); VERIFY_PTR (hashcat_ctx); + hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t)); const int rc_hashcat_init = hashcat_init (hashcat_ctx, event); diff --git a/src/memory.c b/src/memory.c index a566914b2..1626a3acf 100644 --- a/src/memory.c +++ b/src/memory.c @@ -5,16 +5,15 @@ #include "common.h" #include "types.h" -#include "event.h" #include "memory.h" -void *hccalloc (hashcat_ctx_t *hashcat_ctx, const size_t nmemb, const size_t sz) +void *hccalloc (const size_t nmemb, const size_t sz) { void *p = calloc (nmemb, sz); if (p == NULL) { - event_log_error (hashcat_ctx, "%s", MSG_ENOMEM); + fprintf (stderr, "%s\n", MSG_ENOMEM); return (NULL); } @@ -22,13 +21,13 @@ void *hccalloc (hashcat_ctx_t *hashcat_ctx, const size_t nmemb, const size_t sz) return (p); } -void *hcmalloc (hashcat_ctx_t *hashcat_ctx, const size_t sz) +void *hcmalloc (const size_t sz) { void *p = malloc (sz); if (p == NULL) { - event_log_error (hashcat_ctx, "%s", MSG_ENOMEM); + fprintf (stderr, "%s\n", MSG_ENOMEM); return (NULL); } @@ -38,13 +37,13 @@ void *hcmalloc (hashcat_ctx_t *hashcat_ctx, const size_t sz) return (p); } -void *hcrealloc (hashcat_ctx_t *hashcat_ctx, void *ptr, const size_t oldsz, const size_t addsz) +void *hcrealloc (void *ptr, const size_t oldsz, const size_t addsz) { void *p = realloc (ptr, oldsz + addsz); if (p == NULL) { - event_log_error (hashcat_ctx, "%s", MSG_ENOMEM); + fprintf (stderr, "%s\n", MSG_ENOMEM); return (NULL); } @@ -54,11 +53,11 @@ void *hcrealloc (hashcat_ctx_t *hashcat_ctx, void *ptr, const size_t oldsz, cons return (p); } -char *hcstrdup (hashcat_ctx_t *hashcat_ctx, const char *s) +char *hcstrdup (const char *s) { const size_t len = strlen (s); - char *b = (char *) hcmalloc (hashcat_ctx, len + 1); + char *b = (char *) hcmalloc (len + 1); if (b == NULL) return (NULL); diff --git a/src/monitor.c b/src/monitor.c index f406ede27..13dd3644d 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -94,12 +94,12 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) // these variables are mainly used for fan control - int *fan_speed_chgd = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); VERIFY_PTR (fan_speed_chgd); + int *fan_speed_chgd = (int *) hccalloc (opencl_ctx->devices_cnt, sizeof (int)); // temperature controller "loopback" values - int *temp_diff_old = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); VERIFY_PTR (temp_diff_old); - int *temp_diff_sum = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); VERIFY_PTR (temp_diff_sum); + int *temp_diff_old = (int *) hccalloc (opencl_ctx->devices_cnt, sizeof (int)); + int *temp_diff_sum = (int *) hccalloc (opencl_ctx->devices_cnt, sizeof (int)); time_t last_temp_check_time; diff --git a/src/mpsp.c b/src/mpsp.c index d16f81b9e..9c037966c 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -104,7 +104,7 @@ static int mp_css_append_salt (hashcat_ctx_t *hashcat_ctx, salt_t *salt_buf) u32 css_cnt_salt = mask_ctx->css_cnt + salt_len; - cs_t *css_buf_salt = (cs_t *) hccalloc (hashcat_ctx, css_cnt_salt, sizeof (cs_t)); VERIFY_PTR (css_buf_salt); + cs_t *css_buf_salt = (cs_t *) hccalloc (css_cnt_salt, sizeof (cs_t)); memcpy (css_buf_salt, mask_ctx->css_buf, mask_ctx->css_cnt * sizeof (cs_t)); @@ -128,7 +128,7 @@ static int mp_css_unicode_expand (hashcat_ctx_t *hashcat_ctx) u32 css_cnt_unicode = mask_ctx->css_cnt * 2; - cs_t *css_buf_unicode = (cs_t *) hccalloc (hashcat_ctx, css_cnt_unicode, sizeof (cs_t)); VERIFY_PTR (css_buf_unicode); + cs_t *css_buf_unicode = (cs_t *) hccalloc (css_cnt_unicode, sizeof (cs_t)); for (u32 i = 0, j = 0; i < mask_ctx->css_cnt; i += 1, j += 2) { @@ -183,7 +183,7 @@ static int mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_len size_t css_uniq_sz = CHARSIZ * sizeof (u32); - u32 *css_uniq = (u32 *) hcmalloc (hashcat_ctx, css_uniq_sz); VERIFY_PTR (css_uniq); + u32 *css_uniq = (u32 *) hcmalloc (css_uniq_sz); size_t i; @@ -606,7 +606,7 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) * Initialize hcstats */ - u64 *root_stats_buf = (u64 *) hccalloc (hashcat_ctx, SP_ROOT_CNT, sizeof (u64)); VERIFY_PTR (root_stats_buf); + u64 *root_stats_buf = (u64 *) hccalloc (SP_ROOT_CNT, sizeof (u64)); u64 *root_stats_ptr = root_stats_buf; @@ -619,7 +619,7 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) root_stats_ptr += CHARSIZ; } - u64 *markov_stats_buf = (u64 *) hccalloc (hashcat_ctx, SP_MARKOV_CNT, sizeof (u64)); VERIFY_PTR (markov_stats_buf); + u64 *markov_stats_buf = (u64 *) hccalloc (SP_MARKOV_CNT, sizeof (u64)); u64 *markov_stats_ptr = markov_stats_buf; @@ -911,12 +911,12 @@ static int mask_append_final (hashcat_ctx_t *hashcat_ctx, const char *mask) if (mask_ctx->masks_avail == mask_ctx->masks_cnt) { - mask_ctx->masks = (char **) hcrealloc (hashcat_ctx, mask_ctx->masks, mask_ctx->masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *)); VERIFY_PTR (mask_ctx->masks); + mask_ctx->masks = (char **) hcrealloc (mask_ctx->masks, mask_ctx->masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *)); mask_ctx->masks_avail += INCR_MASKS; } - mask_ctx->masks[mask_ctx->masks_cnt] = hcstrdup (hashcat_ctx, mask); + mask_ctx->masks[mask_ctx->masks_cnt] = hcstrdup (mask); mask_ctx->masks_cnt++; @@ -944,7 +944,7 @@ static int mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask) for (u32 increment_len = increment_min; increment_len <= increment_max; increment_len++) { - char *mask_truncated = (char *) hcmalloc (hashcat_ctx, 256); VERIFY_PTR (mask_truncated); + char *mask_truncated = (char *) hcmalloc (256); const int rc_truncated_mask = mp_get_truncated_mask (hashcat_ctx, mask, strlen (mask), increment_len, mask_truncated); @@ -1006,7 +1006,7 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (rc_mask_file == -1) return -1; - mask_ctx->css_buf = (cs_t *) hccalloc (hashcat_ctx, 256, sizeof (cs_t)); VERIFY_PTR (mask_ctx->css_buf); + mask_ctx->css_buf = (cs_t *) hccalloc (256, sizeof (cs_t)); const int rc_gen_css = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, mask_ctx->css_buf, &mask_ctx->css_cnt); @@ -1039,7 +1039,7 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (user_options->attack_mode == ATTACK_MODE_BF) // always true { - mask_ctx->css_buf = (cs_t *) hccalloc (hashcat_ctx, 256, sizeof (cs_t)); VERIFY_PTR (mask_ctx->css_buf); + mask_ctx->css_buf = (cs_t *) hccalloc (256, sizeof (cs_t)); const int rc_gen_css = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, mask_ctx->css_buf, &mask_ctx->css_cnt); @@ -1146,13 +1146,13 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_ctx->enabled = true; - mask_ctx->root_table_buf = (hcstat_table_t *) hccalloc (hashcat_ctx, SP_ROOT_CNT, sizeof (hcstat_table_t)); VERIFY_PTR (mask_ctx->root_table_buf); - mask_ctx->markov_table_buf = (hcstat_table_t *) hccalloc (hashcat_ctx, SP_MARKOV_CNT, sizeof (hcstat_table_t)); VERIFY_PTR (mask_ctx->markov_table_buf); + mask_ctx->root_table_buf = (hcstat_table_t *) hccalloc (SP_ROOT_CNT, sizeof (hcstat_table_t)); + mask_ctx->markov_table_buf = (hcstat_table_t *) hccalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t)); sp_setup_tbl (hashcat_ctx); - mask_ctx->root_css_buf = (cs_t *) hccalloc (hashcat_ctx, SP_PW_MAX, sizeof (cs_t)); VERIFY_PTR (mask_ctx->root_css_buf); - mask_ctx->markov_css_buf = (cs_t *) hccalloc (hashcat_ctx, SP_PW_MAX * CHARSIZ, sizeof (cs_t)); VERIFY_PTR (mask_ctx->markov_css_buf); + mask_ctx->root_css_buf = (cs_t *) hccalloc (SP_PW_MAX, sizeof (cs_t)); + mask_ctx->markov_css_buf = (cs_t *) hccalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t)); mask_ctx->css_cnt = 0; mask_ctx->css_buf = NULL; @@ -1163,7 +1163,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_ctx->masks_pos = 0; mask_ctx->masks_cnt = 0; - mask_ctx->mfs = (mf_t *) hccalloc (hashcat_ctx, MAX_MFS, sizeof (mf_t)); VERIFY_PTR (mask_ctx->mfs); + mask_ctx->mfs = (mf_t *) hccalloc (MAX_MFS, sizeof (mf_t)); mp_setup_sys (mask_ctx->mp_sys); @@ -1214,7 +1214,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); + char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); while (!feof (mask_fp)) { @@ -1291,7 +1291,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); + char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); while (!feof (mask_fp)) { @@ -1349,7 +1349,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); + char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); while (!feof (mask_fp)) { diff --git a/src/opencl.c b/src/opencl.c index 83ad140fe..20cbb7332 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -169,7 +169,7 @@ static int setup_opencl_platforms_filter (hashcat_ctx_t *hashcat_ctx, const char if (opencl_platforms) { - char *platforms = hcstrdup (hashcat_ctx, opencl_platforms); + char *platforms = hcstrdup (opencl_platforms); char *saveptr = NULL; @@ -208,7 +208,7 @@ static int setup_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_ if (opencl_devices) { - char *devices = hcstrdup (hashcat_ctx, opencl_devices); + char *devices = hcstrdup (opencl_devices); char *saveptr = NULL; @@ -247,7 +247,7 @@ static int setup_device_types_filter (hashcat_ctx_t *hashcat_ctx, const char *op if (opencl_device_types) { - char *device_types = hcstrdup (hashcat_ctx, opencl_device_types); + char *device_types = hcstrdup (opencl_device_types); char *saveptr = NULL; @@ -293,7 +293,7 @@ static int read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_fi hc_stat (kernel_file, &st); - char *buf = (char *) hcmalloc (hashcat_ctx, st.st_size + 1); VERIFY_PTR (buf); + char *buf = (char *) hcmalloc (st.st_size + 1); size_t num_read = fread (buf, sizeof (char), st.st_size, fp); @@ -2008,7 +2008,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage == true) return 0; if (user_options->version == true) return 0; - hc_device_param_t *devices_param = (hc_device_param_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hc_device_param_t)); VERIFY_PTR (devices_param); + hc_device_param_t *devices_param = (hc_device_param_t *) hccalloc (DEVICES_MAX, sizeof (hc_device_param_t)); opencl_ctx->devices_param = devices_param; @@ -2016,7 +2016,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) * Load and map OpenCL library calls */ - OCL_PTR *ocl = (OCL_PTR *) hcmalloc (hashcat_ctx, sizeof (OCL_PTR)); VERIFY_PTR (ocl); + OCL_PTR *ocl = (OCL_PTR *) hcmalloc (sizeof (OCL_PTR)); opencl_ctx->ocl = ocl; @@ -2072,14 +2072,14 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) * OpenCL platforms: detect */ - char **platforms_vendor = (char **) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (char *)); VERIFY_PTR (platforms_vendor); - char **platforms_name = (char **) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (char *)); VERIFY_PTR (platforms_name); - char **platforms_version = (char **) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (char *)); VERIFY_PTR (platforms_version); - bool *platforms_skipped = (bool *) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (bool)); VERIFY_PTR (platforms_skipped); + char **platforms_vendor = (char **) hccalloc (CL_PLATFORMS_MAX, sizeof (char *)); + char **platforms_name = (char **) hccalloc (CL_PLATFORMS_MAX, sizeof (char *)); + char **platforms_version = (char **) hccalloc (CL_PLATFORMS_MAX, sizeof (char *)); + bool *platforms_skipped = (bool *) hccalloc (CL_PLATFORMS_MAX, sizeof (bool)); cl_uint platforms_cnt = 0; - cl_platform_id *platforms = (cl_platform_id *) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (cl_platform_id)); VERIFY_PTR (platforms); + cl_platform_id *platforms = (cl_platform_id *) hccalloc (CL_PLATFORMS_MAX, sizeof (cl_platform_id)); cl_uint platform_devices_cnt = 0; - cl_device_id *platform_devices = (cl_device_id *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (cl_device_id)); VERIFY_PTR (platform_devices); + cl_device_id *platform_devices = (cl_device_id *) hccalloc (DEVICES_MAX, sizeof (cl_device_id)); int CL_rc = hc_clGetPlatformIDs (hashcat_ctx, CL_PLATFORMS_MAX, platforms, &platforms_cnt); @@ -2247,7 +2247,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_rc == -1) return -1; - char *platform_vendor = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (platform_vendor); + char *platform_vendor = (char *) hcmalloc (param_value_size); CL_rc = hc_clGetPlatformInfo (hashcat_ctx, platform, CL_PLATFORM_VENDOR, param_value_size, platform_vendor, NULL); @@ -2261,7 +2261,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_rc == -1) return -1; - char *platform_name = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (platform_name); + char *platform_name = (char *) hcmalloc (param_value_size); CL_rc = hc_clGetPlatformInfo (hashcat_ctx, platform, CL_PLATFORM_NAME, param_value_size, platform_name, NULL); @@ -2275,7 +2275,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_rc == -1) return -1; - char *platform_version = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (platform_version); + char *platform_version = (char *) hcmalloc (param_value_size); CL_rc = hc_clGetPlatformInfo (hashcat_ctx, platform, CL_PLATFORM_VERSION, param_value_size, platform_version, NULL); @@ -2383,7 +2383,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_rc == -1) return -1; - char *device_name = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_name); + char *device_name = (char *) hcmalloc (param_value_size); CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NAME, param_value_size, device_name, NULL); @@ -2397,7 +2397,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_rc == -1) return -1; - char *device_vendor = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_vendor); + char *device_vendor = (char *) hcmalloc (param_value_size); CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VENDOR, param_value_size, device_vendor, NULL); @@ -2456,7 +2456,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_rc == -1) return -1; - char *device_version = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_version); + char *device_version = (char *) hcmalloc (param_value_size); CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VERSION, param_value_size, device_version, NULL); @@ -2470,7 +2470,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_rc == -1) return -1; - char *device_opencl_version = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_opencl_version); + char *device_opencl_version = (char *) hcmalloc (param_value_size); CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_OPENCL_C_VERSION, param_value_size, device_opencl_version, NULL); @@ -2597,7 +2597,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_rc == -1) return -1; - char *device_extensions = hcmalloc (hashcat_ctx, device_extensions_size + 1); VERIFY_PTR (device_extensions); + char *device_extensions = hcmalloc (device_extensions_size + 1); CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_EXTENSIONS, device_extensions_size, device_extensions, NULL); @@ -2672,7 +2672,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_rc == -1) return -1; - char *driver_version = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (driver_version); + char *driver_version = (char *) hcmalloc (param_value_size); CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DRIVER_VERSION, param_value_size, driver_version, NULL); @@ -2682,7 +2682,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // device_name_chksum - char *device_name_chksum = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (device_name_chksum); + char *device_name_chksum = (char *) hcmalloc (HCBUFSIZ_TINY); #if defined (__x86_64__) const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%d-%u-%u-%s-%s-%s-%d-%u", 64, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, comptime, user_options->opencl_vector_width); @@ -3716,9 +3716,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * kernel compile or load */ - size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); VERIFY_PTR (kernel_lengths); + size_t *kernel_lengths = (size_t *) hcmalloc (sizeof (size_t)); - char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); VERIFY_PTR (kernel_sources); + char **kernel_sources = (char **) hcmalloc (sizeof (char *)); if (opencl_ctx->force_jit_compilation == -1) { @@ -3752,7 +3752,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) #endif { - char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); + char *build_log = (char *) hcmalloc (build_log_size + 1); int CL_rc_build = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3778,7 +3778,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; - char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); VERIFY_PTR (binary); + char *binary = (char *) hcmalloc (binary_size); CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL); @@ -3854,7 +3854,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) #endif { - char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); + char *build_log = (char *) hcmalloc (build_log_size + 1); int CL_rc_build = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3924,9 +3924,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * kernel compile or load */ - size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); VERIFY_PTR (kernel_lengths); + size_t *kernel_lengths = (size_t *) hcmalloc (sizeof (size_t)); - char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); VERIFY_PTR (kernel_sources); + char **kernel_sources = (char **) hcmalloc (sizeof (char *)); if (cached == 0) { @@ -3958,7 +3958,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) #endif { - char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); + char *build_log = (char *) hcmalloc (build_log_size + 1); int CL_rc_build = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3984,7 +3984,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; - char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); VERIFY_PTR (binary); + char *binary = (char *) hcmalloc (binary_size); CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL); @@ -4066,9 +4066,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * kernel compile or load */ - size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); VERIFY_PTR (kernel_lengths); + size_t *kernel_lengths = (size_t *) hcmalloc (sizeof (size_t)); - char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); VERIFY_PTR (kernel_sources); + char **kernel_sources = (char **) hcmalloc (sizeof (char *)); if (cached == 0) { @@ -4100,7 +4100,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) #endif { - char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); + char *build_log = (char *) hcmalloc (build_log_size + 1); CL_rc = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -4126,7 +4126,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; - char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); VERIFY_PTR (binary); + char *binary = (char *) hcmalloc (binary_size); CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL); @@ -4259,15 +4259,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * main host data */ - pw_t *pws_buf = (pw_t *) hcmalloc (hashcat_ctx, size_pws); VERIFY_PTR (pws_buf); + pw_t *pws_buf = (pw_t *) hcmalloc (size_pws); device_param->pws_buf = pws_buf; - comb_t *combs_buf = (comb_t *) hccalloc (hashcat_ctx, KERNEL_COMBS, sizeof (comb_t)); VERIFY_PTR (combs_buf); + comb_t *combs_buf = (comb_t *) hccalloc (KERNEL_COMBS, sizeof (comb_t)); device_param->combs_buf = combs_buf; - void *hooks_buf = hcmalloc (hashcat_ctx, size_hooks); VERIFY_PTR (hooks_buf); + void *hooks_buf = hcmalloc (size_hooks); device_param->hooks_buf = hooks_buf; diff --git a/src/outfile_check.c b/src/outfile_check.c index 9a2ee0106..8027b7311 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -38,10 +38,10 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx) // buffers hash_t hash_buf = { 0, 0, 0, 0, 0, NULL, 0 }; - hash_buf.digest = hcmalloc (hashcat_ctx, dgst_size); VERIFY_PTR (hash_buf.digest); + hash_buf.digest = hcmalloc (dgst_size); - if (is_salted) hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); VERIFY_PTR (hash_buf.salt); - if (esalt_size) hash_buf.esalt = (void *) hcmalloc (hashcat_ctx, esalt_size); VERIFY_PTR (hash_buf.esalt); + if (is_salted) hash_buf.salt = (salt_t *) hcmalloc (sizeof (salt_t)); + if (esalt_size) hash_buf.esalt = (void *) hcmalloc (esalt_size); u32 digest_buf[64] = { 0 }; @@ -75,7 +75,7 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx) { if (outfile_check_stat.st_mtime > folder_mtime) { - char **out_files_new = scan_directory (hashcat_ctx, root_directory); + char **out_files_new = scan_directory (root_directory); int out_cnt_new = count_dictionaries (out_files_new); @@ -83,7 +83,7 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx) if (out_cnt_new > 0) { - out_info_new = (outfile_data_t *) hccalloc (hashcat_ctx, out_cnt_new, sizeof (outfile_data_t)); VERIFY_PTR (out_info_new); + out_info_new = (outfile_data_t *) hccalloc (out_cnt_new, sizeof (outfile_data_t)); for (int i = 0; i < out_cnt_new; i++) { @@ -140,7 +140,7 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx) fseek (fp, out_info[j].seek, SEEK_SET); - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); + char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); while (!feof (fp)) { @@ -338,7 +338,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->outfile_check_dir == NULL) { - outcheck_ctx->root_directory = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (outcheck_ctx->root_directory); + outcheck_ctx->root_directory = (char *) hcmalloc (HCBUFSIZ_TINY); snprintf (outcheck_ctx->root_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", folder_config->session_dir, user_options->session, OUTFILES_DIR); } diff --git a/src/potfile.c b/src/potfile.c index 507e4cc3d..172de7111 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -96,14 +96,14 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->potfile_path == NULL) { - potfile_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (potfile_ctx->filename); + potfile_ctx->filename = (char *) hcmalloc (HCBUFSIZ_TINY); potfile_ctx->fp = NULL; snprintf (potfile_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.potfile", folder_config->profile_dir); } else { - potfile_ctx->filename = hcstrdup (hashcat_ctx, user_options->potfile_path); VERIFY_PTR (potfile_ctx->filename); + potfile_ctx->filename = hcstrdup (user_options->potfile_path); potfile_ctx->fp = NULL; } @@ -115,13 +115,13 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx) // starting from here, we should allocate some scratch buffer for later use - u8 *out_buf = (u8 *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (out_buf); + u8 *out_buf = (u8 *) hcmalloc (HCBUFSIZ_LARGE); potfile_ctx->out_buf = out_buf; // we need two buffers in parallel - u8 *tmp_buf = (u8 *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (tmp_buf); + u8 *tmp_buf = (u8 *) hcmalloc (HCBUFSIZ_LARGE); potfile_ctx->tmp_buf = tmp_buf; @@ -283,7 +283,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) hash_t hash_buf; - hash_buf.digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size); VERIFY_PTR (hash_buf.digest); + hash_buf.digest = hcmalloc (hashconfig->dgst_size); hash_buf.salt = NULL; hash_buf.esalt = NULL; hash_buf.hash_info = NULL; @@ -291,25 +291,25 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) if (hashconfig->is_salted) { - hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); VERIFY_PTR (hash_buf.salt); + hash_buf.salt = (salt_t *) hcmalloc (sizeof (salt_t)); } if (hashconfig->esalt_size) { - hash_buf.esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size); VERIFY_PTR (hash_buf.esalt); + hash_buf.esalt = hcmalloc (hashconfig->esalt_size); } const int rc = potfile_read_open (hashcat_ctx); if (rc == -1) return -1; - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); + char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); // to be safe work with a copy (because of line_len loop, i etc) // moved up here because it's easier to handle continue case // it's just 64kb - char *line_buf_cpy = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf_cpy); + char *line_buf_cpy = (char *) hcmalloc (HCBUFSIZ_LARGE); while (!feof (potfile_ctx->fp)) { @@ -446,7 +446,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) char *pw_buf = line_buf + line_len; int pw_len = line_len_orig - line_len; - found->pw_buf = (char *) hcmalloc (hashcat_ctx, pw_len + 1); VERIFY_PTR (found->pw_buf); + found->pw_buf = (char *) hcmalloc (pw_len + 1); found->pw_len = pw_len; memcpy (found->pw_buf, pw_buf, pw_len); diff --git a/src/restore.c b/src/restore.c index ee937561f..0c3360af5 100644 --- a/src/restore.c +++ b/src/restore.c @@ -30,7 +30,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) return 0; - restore_data_t *rd = (restore_data_t *) hcmalloc (hashcat_ctx, sizeof (restore_data_t)); VERIFY_PTR (rd); + restore_data_t *rd = (restore_data_t *) hcmalloc (sizeof (restore_data_t)); const size_t nread = fread (rd, sizeof (restore_data_t), 1, fp); @@ -47,7 +47,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) { #if defined (_POSIX) - char *pidbin = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin); + char *pidbin = (char *) hcmalloc (HCBUFSIZ_LARGE); snprintf (pidbin, HCBUFSIZ_LARGE - 1, "/proc/%u/cmdline", rd->pid); @@ -83,8 +83,8 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) HANDLE hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, rd->pid); - char *pidbin = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin); - char *pidbin2 = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin2); + char *pidbin = (char *) hcmalloc (HCBUFSIZ_LARGE); + char *pidbin2 = (char *) hcmalloc (HCBUFSIZ_LARGE); int pidbin_len = GetModuleFileName (NULL, pidbin, HCBUFSIZ_LARGE); int pidbin2_len = GetModuleFileNameEx (hProcess, NULL, pidbin2, HCBUFSIZ_LARGE); @@ -124,7 +124,7 @@ static int init_restore (hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; - restore_data_t *rd = (restore_data_t *) hcmalloc (hashcat_ctx, sizeof (restore_data_t)); VERIFY_PTR (rd); + restore_data_t *rd = (restore_data_t *) hcmalloc (sizeof (restore_data_t)); restore_ctx->rd = rd; @@ -181,9 +181,9 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) return -1; } - rd->argv = (char **) hccalloc (hashcat_ctx, rd->argc, sizeof (char *)); VERIFY_PTR (rd->argv); + rd->argv = (char **) hccalloc (rd->argc, sizeof (char *)); - char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (buf); + char *buf = (char *) hcmalloc (HCBUFSIZ_LARGE); for (u32 i = 0; i < rd->argc; i++) { @@ -200,7 +200,7 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) if (len) buf[len - 1] = 0; - rd->argv[i] = hcstrdup (hashcat_ctx, buf); + rd->argv[i] = hcstrdup (buf); } hcfree (buf); @@ -355,16 +355,16 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) if (user_options->restore_file_path == NULL) { - restore_ctx->eff_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (restore_ctx->eff_restore_file); - restore_ctx->new_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (restore_ctx->new_restore_file); + restore_ctx->eff_restore_file = (char *) hcmalloc (HCBUFSIZ_TINY); + restore_ctx->new_restore_file = (char *) hcmalloc (HCBUFSIZ_TINY); snprintf (restore_ctx->eff_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore", folder_config->session_dir, user_options->session); snprintf (restore_ctx->new_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore.new", folder_config->session_dir, user_options->session); } else { - restore_ctx->eff_restore_file = hcstrdup(hashcat_ctx, user_options->restore_file_path); VERIFY_PTR(restore_ctx->eff_restore_file); - restore_ctx->new_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (restore_ctx->new_restore_file); + restore_ctx->eff_restore_file = hcstrdup (user_options->restore_file_path); + restore_ctx->new_restore_file = (char *) hcmalloc (HCBUFSIZ_TINY); snprintf (restore_ctx->new_restore_file, HCBUFSIZ_TINY - 1, "%s.new", user_options->restore_file_path); } diff --git a/src/rp.c b/src/rp.c index 68b381ed9..c87019e89 100644 --- a/src/rp.c +++ b/src/rp.c @@ -724,12 +724,12 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 if (user_options->rp_files_cnt) { - all_kernel_rules_cnt = (u32 *) hccalloc (hashcat_ctx, user_options->rp_files_cnt, sizeof (u32)); VERIFY_PTR (all_kernel_rules_cnt); + all_kernel_rules_cnt = (u32 *) hccalloc (user_options->rp_files_cnt, sizeof (u32)); - all_kernel_rules_buf = (kernel_rule_t **) hccalloc (hashcat_ctx, user_options->rp_files_cnt, sizeof (kernel_rule_t *)); VERIFY_PTR (all_kernel_rules_buf); + all_kernel_rules_buf = (kernel_rule_t **) hccalloc (user_options->rp_files_cnt, sizeof (kernel_rule_t *)); } - char *rule_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (rule_buf); + char *rule_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); int rule_len = 0; @@ -769,7 +769,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 if (kernel_rules_avail == kernel_rules_cnt) { - kernel_rules_buf = (kernel_rule_t *) hcrealloc (hashcat_ctx, kernel_rules_buf, kernel_rules_avail * sizeof (kernel_rule_t), INCR_RULES * sizeof (kernel_rule_t)); VERIFY_PTR (kernel_rules_buf); + kernel_rules_buf = (kernel_rule_t *) hcrealloc (kernel_rules_buf, kernel_rules_avail * sizeof (kernel_rule_t), INCR_RULES * sizeof (kernel_rule_t)); kernel_rules_avail += INCR_RULES; } @@ -812,7 +812,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 u32 kernel_rules_cnt = 1; - u32 *repeats = (u32 *) hccalloc (hashcat_ctx, user_options->rp_files_cnt + 1, sizeof (u32)); VERIFY_PTR (repeats); + u32 *repeats = (u32 *) hccalloc (user_options->rp_files_cnt + 1, sizeof (u32)); repeats[0] = kernel_rules_cnt; @@ -823,7 +823,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 repeats[i + 1] = kernel_rules_cnt; } - kernel_rule_t *kernel_rules_buf = (kernel_rule_t *) hccalloc (hashcat_ctx, kernel_rules_cnt, sizeof (kernel_rule_t)); VERIFY_PTR (kernel_rules_buf); + kernel_rule_t *kernel_rules_buf = (kernel_rule_t *) hccalloc (kernel_rules_cnt, sizeof (kernel_rule_t)); for (u32 i = 0; i < kernel_rules_cnt; i++) { @@ -875,9 +875,9 @@ int kernel_rules_generate (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, const user_options_t *user_options = hashcat_ctx->user_options; u32 kernel_rules_cnt = 0; - kernel_rule_t *kernel_rules_buf = hccalloc (hashcat_ctx, user_options->rp_gen, sizeof (kernel_rule_t)); VERIFY_PTR (kernel_rules_buf); + kernel_rule_t *kernel_rules_buf = hccalloc (user_options->rp_gen, sizeof (kernel_rule_t)); - char *rule_buf = (char *) hcmalloc (hashcat_ctx, RP_RULE_BUFSIZ); VERIFY_PTR (rule_buf); + char *rule_buf = (char *) hcmalloc (RP_RULE_BUFSIZ); for (kernel_rules_cnt = 0; kernel_rules_cnt < user_options->rp_gen; kernel_rules_cnt++) { diff --git a/src/status.c b/src/status.c index 0b3aeadf4..3299f8c5e 100644 --- a/src/status.c +++ b/src/status.c @@ -1696,9 +1696,9 @@ int status_progress_init (hashcat_ctx_t *hashcat_ctx) status_ctx_t *status_ctx = hashcat_ctx->status_ctx; hashes_t *hashes = hashcat_ctx->hashes; - status_ctx->words_progress_done = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); VERIFY_PTR (status_ctx->words_progress_done); - status_ctx->words_progress_rejected = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); VERIFY_PTR (status_ctx->words_progress_rejected); - status_ctx->words_progress_restored = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); VERIFY_PTR (status_ctx->words_progress_restored); + status_ctx->words_progress_done = (u64 *) hccalloc (hashes->salts_cnt, sizeof (u64)); + status_ctx->words_progress_rejected = (u64 *) hccalloc (hashes->salts_cnt, sizeof (u64)); + status_ctx->words_progress_restored = (u64 *) hccalloc (hashes->salts_cnt, sizeof (u64)); return 0; } @@ -1743,7 +1743,7 @@ int status_ctx_init (hashcat_ctx_t *hashcat_ctx) status_ctx->checkpoint_shutdown = false; - status_ctx->hashcat_status_final = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t)); + status_ctx->hashcat_status_final = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); hc_thread_mutex_init (status_ctx->mux_dispatcher); hc_thread_mutex_init (status_ctx->mux_counter); diff --git a/src/straight.c b/src/straight.c index 521fe56ea..4e534ca6d 100644 --- a/src/straight.c +++ b/src/straight.c @@ -22,12 +22,12 @@ static int straight_ctx_add_wl (hashcat_ctx_t *hashcat_ctx, const char *dict) if (straight_ctx->dicts_avail == straight_ctx->dicts_cnt) { - straight_ctx->dicts = (char **) hcrealloc (hashcat_ctx, straight_ctx->dicts, straight_ctx->dicts_avail * sizeof (char *), INCR_DICTS * sizeof (char *)); VERIFY_PTR (straight_ctx->dicts); + straight_ctx->dicts = (char **) hcrealloc (straight_ctx->dicts, straight_ctx->dicts_avail * sizeof (char *), INCR_DICTS * sizeof (char *)); straight_ctx->dicts_avail += INCR_DICTS; } - straight_ctx->dicts[straight_ctx->dicts_cnt] = hcstrdup (hashcat_ctx, dict); VERIFY_PTR (straight_ctx->dicts[straight_ctx->dicts_cnt]); + straight_ctx->dicts[straight_ctx->dicts_cnt] = hcstrdup (dict); straight_ctx->dicts_cnt++; @@ -196,7 +196,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0)) { - straight_ctx->kernel_rules_buf = (kernel_rule_t *) hcmalloc (hashcat_ctx, sizeof (kernel_rule_t)); VERIFY_PTR (straight_ctx->kernel_rules_buf); + straight_ctx->kernel_rules_buf = (kernel_rule_t *) hcmalloc (sizeof (kernel_rule_t)); straight_ctx->kernel_rules_buf[0].cmds[0] = RULE_OP_MANGLE_NOOP; @@ -281,7 +281,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) { char **dictionary_files = NULL; - dictionary_files = scan_directory (hashcat_ctx, l0_filename); + dictionary_files = scan_directory (l0_filename); if (dictionary_files != NULL) { @@ -354,7 +354,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) { char **dictionary_files = NULL; - dictionary_files = scan_directory (hashcat_ctx, l0_filename); + dictionary_files = scan_directory (l0_filename); if (dictionary_files != NULL) { @@ -418,7 +418,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) { char **dictionary_files = NULL; - dictionary_files = scan_directory (hashcat_ctx, l0_filename); + dictionary_files = scan_directory (l0_filename); if (dictionary_files != NULL) { diff --git a/src/terminal.c b/src/terminal.c index 155a8261a..a8f451d0e 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -589,7 +589,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) { const user_options_t *user_options = hashcat_ctx->user_options; - hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t)); + hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status); @@ -671,7 +671,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) return; } - hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t)); + hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status); @@ -1046,7 +1046,7 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) const u32 hash_mode = hashconfig->hash_mode; - hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t)); + hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status); @@ -1080,7 +1080,7 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) return; } - hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t)); + hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status); diff --git a/src/tuningdb.c b/src/tuningdb.c index 84a05408e..d8c1db5e6 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -67,7 +67,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) tuning_db->enabled = true; - char *tuning_db_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (tuning_db_file); + char *tuning_db_file = (char *) hcmalloc (HCBUFSIZ_TINY); snprintf (tuning_db_file, HCBUFSIZ_TINY - 1, "%s/%s", folder_config->shared_dir, TUNING_DB_FILE); @@ -82,21 +82,21 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) hcfree (tuning_db_file); - int num_lines = count_lines (hashcat_ctx, fp); + int num_lines = count_lines (fp); // a bit over-allocated - tuning_db->alias_buf = (tuning_db_alias_t *) hccalloc (hashcat_ctx, num_lines + 1, sizeof (tuning_db_alias_t)); VERIFY_PTR (tuning_db->alias_buf); + tuning_db->alias_buf = (tuning_db_alias_t *) hccalloc (num_lines + 1, sizeof (tuning_db_alias_t)); tuning_db->alias_cnt = 0; - tuning_db->entry_buf = (tuning_db_entry_t *) hccalloc (hashcat_ctx, num_lines + 1, sizeof (tuning_db_entry_t)); VERIFY_PTR (tuning_db->entry_buf); + tuning_db->entry_buf = (tuning_db_entry_t *) hccalloc (num_lines + 1, sizeof (tuning_db_entry_t)); tuning_db->entry_cnt = 0; rewind (fp); int line_num = 0; - char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (buf); + char *buf = (char *) hcmalloc (HCBUFSIZ_LARGE); while (!feof (fp)) { @@ -140,8 +140,8 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) tuning_db_alias_t *alias = &tuning_db->alias_buf[tuning_db->alias_cnt]; - alias->device_name = hcstrdup (hashcat_ctx, device_name); - alias->alias_name = hcstrdup (hashcat_ctx, alias_name); + alias->device_name = hcstrdup (device_name); + alias->alias_name = hcstrdup (alias_name); tuning_db->alias_cnt++; } @@ -214,7 +214,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) tuning_db_entry_t *entry = &tuning_db->entry_buf[tuning_db->entry_cnt]; - entry->device_name = hcstrdup (hashcat_ctx, device_name); + entry->device_name = hcstrdup (device_name); entry->attack_mode = attack_mode; entry->hash_type = hash_type; entry->vector_width = vector_width; @@ -282,7 +282,7 @@ tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *dev // first we need to convert all spaces in the device_name to underscore - char *device_name_nospace = hcstrdup (hashcat_ctx, device_name); + char *device_name_nospace = hcstrdup (device_name); int device_name_length = strlen (device_name_nospace); diff --git a/src/user_options.c b/src/user_options.c index 958103f70..fb288662e 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -198,7 +198,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->weak_hash_threshold = WEAK_HASH_THRESHOLD; user_options->workload_profile = WORKLOAD_PROFILE; user_options->rp_files_cnt = 0; - user_options->rp_files = (char **) hccalloc (hashcat_ctx, 256, sizeof (char *)); VERIFY_PTR (user_options->rp_files); + user_options->rp_files = (char **) hccalloc (256, sizeof (char *)); user_options->hc_bin = PROGNAME; user_options->hc_argc = 0; user_options->hc_argv = NULL; @@ -992,7 +992,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->quiet = true; user_options->opencl_platforms = NULL; user_options->opencl_devices = NULL; - user_options->opencl_device_types = hcstrdup (hashcat_ctx, "1,2,3"); + user_options->opencl_device_types = hcstrdup ("1,2,3"); } if (user_options->left == true) diff --git a/src/wordlist.c b/src/wordlist.c index 1f648b80c..2c79202dd 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -82,7 +82,7 @@ int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd) { if (wl_data->cnt == wl_data->avail) { - wl_data->buf = (char *) hcrealloc (hashcat_ctx, wl_data->buf, wl_data->avail, wl_data->incr); VERIFY_PTR (wl_data->buf); + wl_data->buf = (char *) hcrealloc (wl_data->buf, wl_data->avail, wl_data->incr); wl_data->avail += wl_data->incr; } @@ -450,7 +450,7 @@ int wl_data_init (hashcat_ctx_t *hashcat_ctx) wl_data->enabled = true; - wl_data->buf = (char *) hcmalloc (hashcat_ctx, user_options->segment_size); VERIFY_PTR (wl_data->buf); + wl_data->buf = (char *) hcmalloc (user_options->segment_size); wl_data->avail = user_options->segment_size; wl_data->incr = user_options->segment_size; wl_data->cnt = 0;