1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-22 06:38:11 +00:00

Removed exit() from memory.c, resulting in all exit() calls removed from all code in the repository

This commit is contained in:
jsteube 2016-10-13 10:07:04 +02:00
parent 62284f79b1
commit 8598a79732
36 changed files with 513 additions and 408 deletions

View File

@ -8,7 +8,7 @@
#include <string.h>
void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx);
int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx);
void bitmap_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
#endif // _BITMAP_H

View File

@ -1507,7 +1507,7 @@ char *strparser (const u32 parser_status);
void to_hccap_t (hashcat_ctx_t *hashcat_ctx, hccap_t *hccap, const u32 salt_pos, const u32 digest_pos);
void ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, const u32 digest_pos);
int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, const u32 digest_pos);
int hashconfig_init (hashcat_ctx_t *hashcat_ctx);
void hashconfig_destroy (hashcat_ctx_t *hashcat_ctx);

View File

@ -12,6 +12,8 @@
#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);

View File

@ -22,18 +22,18 @@ void *hc_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size
int potfile_init (hashcat_ctx_t *hashcat_ctx);
int potfile_read_open (hashcat_ctx_t *hashcat_ctx);
void potfile_read_parse (hashcat_ctx_t *hashcat_ctx);
int potfile_read_parse (hashcat_ctx_t *hashcat_ctx);
void potfile_read_close (hashcat_ctx_t *hashcat_ctx);
int potfile_write_open (hashcat_ctx_t *hashcat_ctx);
void potfile_write_close (hashcat_ctx_t *hashcat_ctx);
void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len);
void potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num);
int potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num);
void potfile_hash_free (hashcat_ctx_t *hashcat_ctx);
void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *));
void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *));
void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *));
void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *));
void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx);
int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *));
int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *));
int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx);
void potfile_destroy (hashcat_ctx_t *hashcat_ctx);
#endif // _POTFILE_H

View File

@ -156,7 +156,7 @@ typedef enum user_options_map
} user_options_map_t;
void user_options_init (hashcat_ctx_t *hashcat_ctx);
int user_options_init (hashcat_ctx_t *hashcat_ctx);
void user_options_destroy (hashcat_ctx_t *hashcat_ctx);

View File

@ -18,9 +18,9 @@ void get_next_word_uc (char *buf, u64 sz, u64 *len, u64 *off);
void get_next_word_std (char *buf, u64 sz, u64 *len, u64 *off);
void get_next_word (hashcat_ctx_t *hashcat_ctx, FILE *fd, char **out_buf, u32 *out_len);
void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd);
int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd);
u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile);
void wl_data_init (hashcat_ctx_t *hashcat_ctx);
int wl_data_init (hashcat_ctx_t *hashcat_ctx);
void wl_data_destroy (hashcat_ctx_t *hashcat_ctx);
#endif // _WORDLIST_H

View File

@ -49,7 +49,7 @@ static u32 generate_bitmaps (const u32 digests_cnt, const u32 dgst_size, const u
return collisions;
}
void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx)
int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx)
{
bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
@ -58,12 +58,12 @@ void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx)
bitmap_ctx->enabled = false;
if (user_options->keyspace == true) return;
if (user_options->left == true) return;
if (user_options->opencl_info == true) return;
if (user_options->show == true) return;
if (user_options->usage == true) return;
if (user_options->version == true) return;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->opencl_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
bitmap_ctx->enabled = true;
@ -77,14 +77,14 @@ void 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));
u32 *bitmap_s1_b = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s1_c = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s1_d = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s2_a = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s2_b = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s2_c = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s2_d = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32));
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_bits;
u32 bitmap_nums;
@ -131,6 +131,8 @@ void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx)
bitmap_ctx->bitmap_s2_b = bitmap_s2_b;
bitmap_ctx->bitmap_s2_c = bitmap_s2_c;
bitmap_ctx->bitmap_s2_d = bitmap_s2_d;
return 0;
}
void bitmap_ctx_destroy (hashcat_ctx_t *hashcat_ctx)

View File

@ -30,7 +30,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
combinator_ctx->enabled = true;
combinator_ctx->scratch_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
combinator_ctx->scratch_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (combinator_ctx->scratch_buf);
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{

View File

@ -25,7 +25,7 @@ int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx)
cpt_ctx->enabled = true;
cpt_ctx->cpt_buf = (cpt_t *) hccalloc (hashcat_ctx, CPT_BUF, sizeof (cpt_t));
cpt_ctx->cpt_buf = (cpt_t *) hccalloc (hashcat_ctx, CPT_BUF, sizeof (cpt_t)); VERIFY_PTR (cpt_ctx->cpt_buf);
cpt_ctx->cpt_total = 0;
cpt_ctx->cpt_pos = 0;

View File

@ -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);
u8 *buf = (u8 *) hcmalloc (hashcat_ctx, MAX_KEY_SIZE + 1); VERIFY_PTR (buf);
int nread = fread (buf, sizeof (u8), MAX_KEY_SIZE, fd);

View File

@ -42,8 +42,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);
dictstat_ctx->base = (dictstat_t *) hccalloc (hashcat_ctx, MAX_DICTSTAT, sizeof (dictstat_t));
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->cnt = 0;
snprintf (dictstat_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.dictstat", folder_config->profile_dir);

View File

@ -104,7 +104,7 @@ static u32 get_work (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
return work;
}
static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
{
user_options_t *user_options = hashcat_ctx->user_options;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
@ -113,7 +113,7 @@ static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_pa
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);
char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (buf);
const u32 attack_kern = user_options_extra->attack_kern;
@ -224,6 +224,8 @@ static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_pa
device_param->kernel_loops = 0;
hcfree (buf);
return 0;
}
void *thread_calc_stdin (void *p)
@ -240,12 +242,12 @@ void *thread_calc_stdin (void *p)
if (device_param->skipped) return NULL;
calc_stdin (hashcat_ctx, device_param);
calc_stdin (hashcat_ctx, device_param); // we should check the RC here
return NULL;
}
static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
{
user_options_t *user_options = hashcat_ctx->user_options;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
@ -316,7 +318,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
{
event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno));
return;
return -1;
}
if (attack_mode == ATTACK_MODE_COMBI)
@ -335,7 +337,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
fclose (fd);
return;
return -1;
}
device_param->combs_fp = combs_fp;
@ -352,14 +354,14 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
fclose (fd);
return;
return -1;
}
device_param->combs_fp = combs_fp;
}
}
hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_ctx_t));
hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_ctx_t)); VERIFY_PTR (hashcat_ctx_tmp);
/*
hashcat_ctx_tmp->bitmap_ctx = hashcat_ctx->bitmap_ctx;
@ -389,9 +391,11 @@ static void 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));
hashcat_ctx_tmp->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t)); VERIFY_PTR (hashcat_ctx_tmp->wl_data);
wl_data_init (hashcat_ctx_tmp);
const int rc_wl_data_init = wl_data_init (hashcat_ctx_tmp);
if (rc_wl_data_init == -1) return -1;
u64 words_cur = 0;
@ -543,6 +547,8 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
device_param->kernel_accel = 0;
device_param->kernel_loops = 0;
return 0;
}
void *thread_calc (void *p)
@ -559,7 +565,7 @@ void *thread_calc (void *p)
if (device_param->skipped) return NULL;
calc (hashcat_ctx, device_param);
calc (hashcat_ctx, device_param); // we should check the RC here
return NULL;
}

View File

@ -12,7 +12,7 @@ u64 count_lines (hashcat_ctx_t *hashcat_ctx, FILE *fd)
{
u64 cnt = 0;
char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE + 1);
char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE + 1); VERIFY_PTR (buf);
char prev = '\n';

View File

@ -26,29 +26,25 @@ int sort_by_stringptr (const void *p1, const void *p2)
return strcmp (*s1, *s2);
}
static char *get_exec_path (hashcat_ctx_t *hashcat_ctx)
static int get_exec_path (char *exec_path, const size_t exec_path_sz)
{
size_t exec_path_len = 1024;
char *exec_path = (char *) hcmalloc (hashcat_ctx, exec_path_len);
#if defined (__linux__)
char tmp[32] = { 0 };
snprintf (tmp, sizeof (tmp) - 1, "/proc/%d/exe", getpid ());
const int len = readlink (tmp, exec_path, exec_path_len - 1);
const int len = readlink (tmp, exec_path, exec_path_sz - 1);
#elif defined (_WIN)
const int len = GetModuleFileName (NULL, exec_path, exec_path_len - 1);
const int len = GetModuleFileName (NULL, exec_path, exec_path_sz - 1);
#elif defined (__APPLE__)
u32 size = (u32) exec_path_len;
u32 size = (u32) exec_path_sz;
if (_NSGetExecutablePath (exec_path, &size) != 0) return NULL;
if (_NSGetExecutablePath (exec_path, &size) != 0) return -1;
const size_t len = strlen (exec_path);
@ -63,11 +59,11 @@ static char *get_exec_path (hashcat_ctx_t *hashcat_ctx)
char tmp[32] = { 0 };
size_t size = exec_path_len;
size_t size = exec_path_sz;
sysctl (mib, 4, exec_path, &size, NULL, 0);
const int len = readlink (tmp, exec_path, exec_path_len - 1);
const int len = readlink (tmp, exec_path, exec_path_sz - 1);
#else
#error Your Operating System is not supported or detected
@ -75,13 +71,14 @@ static char *get_exec_path (hashcat_ctx_t *hashcat_ctx)
exec_path[len] = 0;
return exec_path;
return 0;
}
char *get_install_dir (hashcat_ctx_t *hashcat_ctx, const char *progname)
static void get_install_dir (char *install_dir, const char *exec_path)
{
char *install_dir = hcstrdup (hashcat_ctx, progname);
char *last_slash = NULL;
strncpy (install_dir, exec_path, HCBUFSIZ_TINY - 1);
char *last_slash = NULL;
if ((last_slash = strrchr (install_dir, '/')) != NULL)
{
@ -96,26 +93,16 @@ char *get_install_dir (hashcat_ctx_t *hashcat_ctx, const char *progname)
install_dir[0] = '.';
install_dir[1] = 0;
}
return (install_dir);
}
char *get_profile_dir (hashcat_ctx_t *hashcat_ctx, const char *homedir)
static void get_profile_dir (char *profile_dir, const char *home_dir)
{
char *profile_dir = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY + 1);
snprintf (profile_dir, HCBUFSIZ_TINY - 1, "%s/%s", homedir, DOT_HASHCAT);
return profile_dir;
snprintf (profile_dir, HCBUFSIZ_TINY - 1, "%s/%s", home_dir, DOT_HASHCAT);
}
char *get_session_dir (hashcat_ctx_t *hashcat_ctx, const char *profile_dir)
static void get_session_dir (char *session_dir, const char *profile_dir)
{
char *session_dir = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY);
snprintf (session_dir, HCBUFSIZ_TINY - 1, "%s/%s", profile_dir, SESSIONS_FOLDER);
return session_dir;
}
int count_dictionaries (char **dictionary_files)
@ -147,7 +134,7 @@ char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path)
char **files = NULL;
int num_files = 0;
size_t num_files = 0;
DIR *d = NULL;
@ -178,13 +165,9 @@ char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path)
if ((strcmp (de->d_name, ".") == 0) || (strcmp (de->d_name, "..") == 0)) continue;
size_t path_size = strlen (tmp_path) + 1 + strlen (de->d_name);
char *path_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY);
char *path_file = (char *) hcmalloc (hashcat_ctx, path_size + 1);
snprintf (path_file, path_size + 1, "%s/%s", tmp_path, de->d_name);
path_file[path_size] = 0;
snprintf (path_file, HCBUFSIZ_TINY - 1, "%s/%s", tmp_path, de->d_name);
DIR *d_test;
@ -196,11 +179,11 @@ char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path)
}
else
{
files = (char **) hcrealloc (hashcat_ctx, files, (size_t) num_files * sizeof (char *), sizeof (char *));
files = (char **) hcrealloc (hashcat_ctx, files, (num_files + 1) * sizeof (char *), sizeof (char *));
files[num_files] = path_file;
num_files++;
files[num_files - 1] = path_file;
}
}
@ -208,19 +191,19 @@ char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path)
}
else if (errno == ENOTDIR)
{
files = (char **) hcrealloc (hashcat_ctx, files, (size_t) num_files * sizeof (char *), sizeof (char *));
files = (char **) hcrealloc (hashcat_ctx, files, (num_files + 1) * sizeof (char *), sizeof (char *));
files[num_files] = hcstrdup (hashcat_ctx, path);
num_files++;
files[num_files - 1] = hcstrdup (hashcat_ctx, path);
}
files = (char **) hcrealloc (hashcat_ctx, files, (size_t) num_files * sizeof (char *), sizeof (char *));
files = (char **) hcrealloc (hashcat_ctx, files, (num_files + 1) * sizeof (char *), sizeof (char *));
files[num_files] = NULL;
num_files++;
files[num_files - 1] = NULL;
hcfree (tmp_path);
return (files);
@ -237,7 +220,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);
char *cwd = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (cwd);
if (getcwd (cwd, HCBUFSIZ_TINY - 1) == NULL)
{
@ -250,9 +233,13 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins
* folders, as discussed on https://github.com/hashcat/hashcat/issues/20
*/
char *exec_path = get_exec_path (hashcat_ctx);
const size_t exec_path_sz = 1024;
if (exec_path == NULL)
char *exec_path = (char *) hcmalloc (hashcat_ctx, exec_path_sz); VERIFY_PTR (exec_path);
const int rc = get_exec_path (exec_path, exec_path_sz);
if (rc == -1)
{
event_log_error (hashcat_ctx, "get_exec_path() failed");
@ -280,7 +267,10 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins
return -1;
}
char *install_dir = get_install_dir (hashcat_ctx, resolved_exec_path);
char *install_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (install_dir);
get_install_dir (install_dir, resolved_exec_path);
char *profile_dir = NULL;
char *session_dir = NULL;
char *shared_dir = NULL;
@ -289,11 +279,15 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins
{
struct passwd *pw = getpwuid (getuid ());
const char *homedir = pw->pw_dir;
const char *home_dir = pw->pw_dir;
profile_dir = get_profile_dir (hashcat_ctx, homedir);
session_dir = get_session_dir (hashcat_ctx, profile_dir);
shared_dir = hcstrdup (hashcat_ctx, shared_folder);
profile_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (profile_dir);
session_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (session_dir);
get_profile_dir (profile_dir, home_dir);
get_session_dir (session_dir, profile_dir);
shared_dir = hcstrdup (hashcat_ctx, shared_folder);
hc_mkdir (profile_dir, 0700);
hc_mkdir (session_dir, 0700);
@ -310,7 +304,10 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins
#else
char *install_dir = get_install_dir (hashcat_ctx, exec_path);
char *install_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (install_dir);
get_install_dir (install_dir, exec_path);
char *profile_dir = install_dir;
char *session_dir = install_dir;
char *shared_dir = install_dir;
@ -326,13 +323,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);
char *cpath = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (cpath);
#if defined (_WIN)
snprintf (cpath, HCBUFSIZ_TINY - 1, "%s\\OpenCL\\", shared_dir);
char *cpath_real = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY);
char *cpath_real = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (cpath_real);
if (GetFullPathName (cpath, HCBUFSIZ_TINY - 1, cpath_real, NULL) == 0)
{
@ -345,7 +342,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);
char *cpath_real = (char *) hcmalloc (hashcat_ctx, PATH_MAX); VERIFY_PTR (cpath_real);
if (realpath (cpath, cpath_real) == NULL)
{
@ -385,7 +382,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);
char *kernels_folder = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (kernels_folder);
snprintf (kernels_folder, HCBUFSIZ_TINY - 1, "%s/kernels", profile_dir);

View File

@ -66,32 +66,32 @@ int hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, stru
hashcat_ctx->event = event;
hashcat_ctx->bitmap_ctx = (bitmap_ctx_t *) hcmalloc (hashcat_ctx, sizeof (bitmap_ctx_t));
hashcat_ctx->combinator_ctx = (combinator_ctx_t *) hcmalloc (hashcat_ctx, sizeof (combinator_ctx_t));
hashcat_ctx->cpt_ctx = (cpt_ctx_t *) hcmalloc (hashcat_ctx, sizeof (cpt_ctx_t));
hashcat_ctx->debugfile_ctx = (debugfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (debugfile_ctx_t));
hashcat_ctx->dictstat_ctx = (dictstat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (dictstat_ctx_t));
hashcat_ctx->event_ctx = (event_ctx_t *) hcmalloc (hashcat_ctx, sizeof (event_ctx_t));
hashcat_ctx->folder_config = (folder_config_t *) hcmalloc (hashcat_ctx, sizeof (folder_config_t));
hashcat_ctx->hashcat_user = (hashcat_user_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_user_t));
hashcat_ctx->hashconfig = (hashconfig_t *) hcmalloc (hashcat_ctx, sizeof (hashconfig_t));
hashcat_ctx->hashes = (hashes_t *) hcmalloc (hashcat_ctx, sizeof (hashes_t));
hashcat_ctx->hwmon_ctx = (hwmon_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hwmon_ctx_t));
hashcat_ctx->induct_ctx = (induct_ctx_t *) hcmalloc (hashcat_ctx, sizeof (induct_ctx_t));
hashcat_ctx->logfile_ctx = (logfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (logfile_ctx_t));
hashcat_ctx->loopback_ctx = (loopback_ctx_t *) hcmalloc (hashcat_ctx, sizeof (loopback_ctx_t));
hashcat_ctx->mask_ctx = (mask_ctx_t *) hcmalloc (hashcat_ctx, sizeof (mask_ctx_t));
hashcat_ctx->opencl_ctx = (opencl_ctx_t *) hcmalloc (hashcat_ctx, sizeof (opencl_ctx_t));
hashcat_ctx->outcheck_ctx = (outcheck_ctx_t *) hcmalloc (hashcat_ctx, sizeof (outcheck_ctx_t));
hashcat_ctx->outfile_ctx = (outfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (outfile_ctx_t));
hashcat_ctx->potfile_ctx = (potfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (potfile_ctx_t));
hashcat_ctx->restore_ctx = (restore_ctx_t *) hcmalloc (hashcat_ctx, sizeof (restore_ctx_t));
hashcat_ctx->status_ctx = (status_ctx_t *) hcmalloc (hashcat_ctx, sizeof (status_ctx_t));
hashcat_ctx->straight_ctx = (straight_ctx_t *) hcmalloc (hashcat_ctx, sizeof (straight_ctx_t));
hashcat_ctx->tuning_db = (tuning_db_t *) hcmalloc (hashcat_ctx, sizeof (tuning_db_t));
hashcat_ctx->user_options_extra = (user_options_extra_t *) hcmalloc (hashcat_ctx, sizeof (user_options_extra_t));
hashcat_ctx->user_options = (user_options_t *) hcmalloc (hashcat_ctx, sizeof (user_options_t));
hashcat_ctx->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t));
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);
return 0;
}
@ -231,9 +231,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));
thread_param_t *threads_param = (thread_param_t *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (thread_param_t)); VERIFY_PTR (threads_param);
hc_thread_t *c_threads = (hc_thread_t *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (hc_thread_t));
hc_thread_t *c_threads = (hc_thread_t *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (hc_thread_t)); VERIFY_PTR (c_threads);
status_ctx->devices_status = STATUS_AUTOTUNE;
@ -475,8 +475,12 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
{
outfile_write_open (hashcat_ctx);
potfile_read_open (hashcat_ctx);
potfile_read_parse (hashcat_ctx);
potfile_read_open (hashcat_ctx);
const int rc = potfile_read_parse (hashcat_ctx);
if (rc == -1) return -1;
potfile_read_close (hashcat_ctx);
}
@ -567,7 +571,9 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
EVENT (EVENT_BITMAP_INIT_PRE);
bitmap_ctx_init (hashcat_ctx);
const int rc_bitmap_init = bitmap_ctx_init (hashcat_ctx);
if (rc_bitmap_init == -1) return -1;
EVENT (EVENT_BITMAP_INIT_POST);
@ -581,7 +587,9 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
* Wordlist allocate buffer
*/
wl_data_init (hashcat_ctx);
const int rc_wl_data_init = wl_data_init (hashcat_ctx);
if (rc_wl_data_init == -1) return -1;
/**
* straight mode init
@ -700,7 +708,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));
hc_thread_t *inner_threads = (hc_thread_t *) hccalloc (hashcat_ctx, 10, sizeof (hc_thread_t)); VERIFY_PTR (inner_threads);
status_ctx->shutdown_inner = false;

View File

@ -339,7 +339,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
event_log_info_nn (hashcat_ctx, "");
plain_t *cracked = (plain_t *) hccalloc (hashcat_ctx, num_cracked, sizeof (plain_t));
plain_t *cracked = (plain_t *) hccalloc (hashcat_ctx, num_cracked, sizeof (plain_t)); VERIFY_PTR (cracked);
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);
@ -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));
hashes_buf = (hash_t *) hccalloc (hashcat_ctx, hashes_avail, sizeof (hash_t)); VERIFY_PTR (hashes_buf);
digests_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->dgst_size);
digests_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->dgst_size); VERIFY_PTR (digests_buf);
if ((user_options->username && (user_options->remove || user_options->show)) || (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));
hashinfo_t *hash_info = (hashinfo_t *) hcmalloc (hashcat_ctx, sizeof (hashinfo_t)); VERIFY_PTR (hash_info);
hashes_buf[hash_pos].hash_info = hash_info;
if (user_options->username && (user_options->remove || user_options->show || user_options->left))
{
hash_info->user = (user_t*) hcmalloc (hashcat_ctx, sizeof (user_t));
hash_info->user = (user_t*) hcmalloc (hashcat_ctx, sizeof (user_t)); VERIFY_PTR (hash_info->user);
}
if (user_options->benchmark)
{
hash_info->orighash = (char *) hcmalloc (hashcat_ctx, 256);
hash_info->orighash = (char *) hcmalloc (hashcat_ctx, 256); VERIFY_PTR (hash_info->orighash);
}
}
}
if (hashconfig->is_salted)
{
salts_buf = (salt_t *) hccalloc (hashcat_ctx, hashes_avail, sizeof (salt_t));
salts_buf = (salt_t *) hccalloc (hashcat_ctx, hashes_avail, sizeof (salt_t)); VERIFY_PTR (salts_buf);
if (hashconfig->esalt_size)
{
esalts_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->esalt_size);
esalts_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->esalt_size); VERIFY_PTR (esalts_buf);
}
}
else
{
salts_buf = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t));
salts_buf = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t)); VERIFY_PTR (salts_buf);
}
for (u32 hash_pos = 0; hash_pos < hashes_avail; hash_pos++)
@ -720,7 +720,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
u32 hccap_size = sizeof (hccap_t);
char *in = (char *) hcmalloc (hashcat_ctx, hccap_size);
char *in = (char *) hcmalloc (hashcat_ctx, hccap_size); VERIFY_PTR (in);
while (!feof (fp))
{
@ -891,7 +891,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
u32 line_num = 0;
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf);
while (!feof (fp))
{
@ -929,7 +929,7 @@ 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));
*user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); VERIFY_PTR (*user);
user_t *user_ptr = *user;
@ -1108,22 +1108,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);
void *digests_buf_new = (void *) hccalloc (hashcat_ctx, hashes_cnt, hashconfig->dgst_size); VERIFY_PTR (digests_buf_new);
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));
salts_buf_new = (salt_t *) hccalloc (hashcat_ctx, hashes_cnt, sizeof (salt_t)); VERIFY_PTR (salts_buf_new);
if (hashconfig->esalt_size)
{
esalts_buf_new = (void *) hccalloc (hashcat_ctx, hashes_cnt, hashconfig->esalt_size);
esalts_buf_new = (void *) hccalloc (hashcat_ctx, hashes_cnt, hashconfig->esalt_size); VERIFY_PTR (esalts_buf_new);
}
}
else
{
salts_buf_new = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t));
salts_buf_new = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t)); VERIFY_PTR (salts_buf_new);
}
if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Structuring salts for cracking task...");
@ -1131,8 +1131,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));
u32 *digests_shown_tmp = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32));
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 salts_cnt = 0;
u32 salts_done = 0;
@ -1141,7 +1141,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY))
{
hash_info = (hashinfo_t **) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t *));
hash_info = (hashinfo_t **) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t *)); VERIFY_PTR (hash_info);
if (user_options->username && (user_options->remove || user_options->show))
{
@ -1149,14 +1149,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 *) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t));
hash_info[user_pos] = (hashinfo_t *) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t)); VERIFY_PTR (hash_info[user_pos]);
hash_info[user_pos]->user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t));
hash_info[user_pos]->user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); VERIFY_PTR (hash_info[user_pos]->user);
}
}
}
u32 *salts_shown = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32));
u32 *salts_shown = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); VERIFY_PTR (salts_shown);
salt_t *salt_buf;

View File

@ -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));
u32 *formats_cnt = (u32 *) hccalloc (hashcat_ctx, HLFMTS_CNT, sizeof (u32)); VERIFY_PTR (formats_cnt);
u32 num_check = 0;
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf);
while (!feof (fp))
{

View File

@ -29,7 +29,7 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx)
DWORD Type = REG_SZ;
char *Buffer = (char *) hcmalloc (hashcat_ctx, BufferSize + 1);
char *Buffer = (char *) hcmalloc (hashcat_ctx, BufferSize + 1); VERIFY_PTR (Buffer);
HKEY hKey = 0;
@ -1861,15 +1861,9 @@ static int get_adapters_num_adl (hashcat_ctx_t *hashcat_ctx, int *iNumberAdapter
return 0;
}
static LPAdapterInfo hm_get_adapter_info_adl (hashcat_ctx_t *hashcat_ctx, int iNumberAdapters)
static int hm_get_adapter_info_adl (hashcat_ctx_t *hashcat_ctx, LPAdapterInfo lpAdapterInfo, const size_t AdapterInfoSize)
{
size_t AdapterInfoSize = iNumberAdapters * sizeof (AdapterInfo);
LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) hcmalloc (hashcat_ctx, AdapterInfoSize);
if (hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx, lpAdapterInfo, AdapterInfoSize) == -1) return NULL;
return lpAdapterInfo;
return hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx, lpAdapterInfo, AdapterInfoSize);
}
static int hm_get_adapter_index_nvapi (hashcat_ctx_t *hashcat_ctx, HM_ADAPTER_NVAPI *nvapiGPUHandle)
@ -2001,14 +1995,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));
adl_adapters = (u32 *) hcrealloc (hashcat_ctx, 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));
device_numbers = (int*) hcrealloc (hashcat_ctx, device_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int));
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[*num_adl_adapters] = info.iBusNumber;
device_numbers[*num_adl_adapters] = info.iDeviceNumber;
@ -2732,7 +2726,7 @@ 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));
hwmon_ctx->hm_device = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); VERIFY_PTR (hwmon_ctx->hm_device);
/**
* Initialize shared libraries
@ -2743,10 +2737,10 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
NVML_PTR *nvml = (NVML_PTR *) hcmalloc (hashcat_ctx, sizeof (NVML_PTR));
XNVCTRL_PTR *xnvctrl = (XNVCTRL_PTR *) hcmalloc (hashcat_ctx, sizeof (XNVCTRL_PTR));
hm_attrs_t *hm_adapters_adl = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t));
hm_attrs_t *hm_adapters_nvapi = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t));
hm_attrs_t *hm_adapters_nvml = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t));
hm_attrs_t *hm_adapters_xnvctrl = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t));
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);
if (opencl_ctx->need_nvml == true)
{
@ -2800,7 +2794,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));
HM_ADAPTER_NVML *nvmlGPUHandle = (HM_ADAPTER_NVML *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (HM_ADAPTER_NVML)); VERIFY_PTR (nvmlGPUHandle);
int tmp_in = hm_get_adapter_index_nvml (hashcat_ctx, nvmlGPUHandle);
@ -2830,7 +2824,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));
HM_ADAPTER_NVAPI *nvGPUHandle = (HM_ADAPTER_NVAPI *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (HM_ADAPTER_NVAPI)); VERIFY_PTR (nvGPUHandle);
int tmp_in = hm_get_adapter_index_nvapi (hashcat_ctx, nvGPUHandle);
@ -2876,9 +2870,11 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
// adapter info
LPAdapterInfo lpAdapterInfo = hm_get_adapter_info_adl (hashcat_ctx, hm_adapters_num);
LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) hccalloc (hashcat_ctx, hm_adapters_num, sizeof (AdapterInfo)); VERIFY_PTR (lpAdapterInfo);
if (lpAdapterInfo == NULL) return -1;
const int rc_adapter_info_adl = hm_get_adapter_info_adl (hashcat_ctx, lpAdapterInfo, hm_adapters_num * sizeof (AdapterInfo));
if (rc_adapter_info_adl == -1) return -1;
// get a list (of ids of) valid/usable adapters
@ -2916,11 +2912,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));
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_power_control_status = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int));
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->nvml_power_limit = (unsigned int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (unsigned 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);
/**
* HM devices: copy
@ -3071,7 +3067,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));
ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) hccalloc (hashcat_ctx, 1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); VERIFY_PTR (performance_state);
performance_state->iNumberOfPerformanceLevels = 2;

View File

@ -46,7 +46,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);
char *root_directory = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (root_directory);
snprintf (root_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", folder_config->session_dir, user_options->session, INDUCT_DIR);
@ -58,7 +58,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx)
}
else if (errno == ENOTEMPTY)
{
char *root_directory_mv = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY);
char *root_directory_mv = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (root_directory_mv);
snprintf (root_directory_mv, HCBUFSIZ_TINY - 1, "%s/%s.induct.%d", folder_config->session_dir, user_options->session, (int) status_ctx->proc_start);

View File

@ -12934,7 +12934,7 @@ void to_hccap_t (hashcat_ctx_t *hashcat_ctx, hccap_t *hccap, const u32 salt_pos,
}
}
void ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, const u32 digest_pos)
int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, const u32 digest_pos)
{
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
const hashes_t *hashes = hashcat_ctx->hashes;
@ -15039,9 +15039,9 @@ void ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos
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);
char *ckey_buf = (char *) hcmalloc (hashcat_ctx, (ckey_len * 2) + 1);
char *public_key_buf = (char *) hcmalloc (hashcat_ctx, (public_key_len * 2) + 1);
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);
for (u32 i = 0, j = 0; i < cry_master_len; i += 1, j += 2)
{
@ -15098,7 +15098,7 @@ void ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos
const u32 data_len = seven_zip->data_len;
char *data_buf = (char *) hcmalloc (hashcat_ctx, (data_len * 2) + 1);
char *data_buf = (char *) hcmalloc (hashcat_ctx, (data_len * 2) + 1); VERIFY_PTR (data_buf);
for (u32 i = 0, j = 0; i < data_len; i += 1, j += 2)
{
@ -15919,6 +15919,8 @@ void ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos
out_buf[pos + 1 + salt.salt_len] = 0;
}
return 0;
}
int hashconfig_init (hashcat_ctx_t *hashcat_ctx)

View File

@ -77,12 +77,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);
logfile_ctx->logfile = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (logfile_ctx->logfile);
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);
logfile_ctx->topid = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY);
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->enabled = true;

View File

@ -70,7 +70,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);
loopback_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (loopback_ctx->filename);
return 0;
}

View File

@ -119,7 +119,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));
hashcat_user->outer_threads = (hc_thread_t *) hccalloc (hashcat_ctx, 2, sizeof (hc_thread_t)); if (hashcat_user->outer_threads == NULL) return;
status_ctx->shutdown_outer = false;
@ -487,7 +487,7 @@ int main (int argc, char **argv)
{
// hashcat main context
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t));
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t)); VERIFY_PTR (hashcat_ctx);
const int rc_hashcat_init = hashcat_ctx_init (hashcat_ctx, event);
@ -513,7 +513,9 @@ int main (int argc, char **argv)
// initialize the user options with some defaults (you can override them later)
user_options_init (hashcat_ctx);
const int rc_options_init = user_options_init (hashcat_ctx);
if (rc_options_init == -1) return -1;
// parse commandline parameters and check them
@ -558,7 +560,9 @@ int main (int argc, char **argv)
// initialize the user options with some defaults (you can override them later)
user_options_init (hashcat_ctx);
const int rc_options_init = user_options_init (hashcat_ctx);
if (rc_options_init == -1) return -1;
// your own stuff

View File

@ -16,7 +16,7 @@ void *hccalloc (hashcat_ctx_t *hashcat_ctx, const size_t nmemb, const size_t sz)
{
event_log_error (hashcat_ctx, "%s", MSG_ENOMEM);
exit (-1);
return (NULL);
}
return (p);
@ -30,7 +30,7 @@ void *hcmalloc (hashcat_ctx_t *hashcat_ctx, const size_t sz)
{
event_log_error (hashcat_ctx, "%s", MSG_ENOMEM);
exit (-1);
return (NULL);
}
memset (p, 0, sz);
@ -46,7 +46,7 @@ void *hcrealloc (hashcat_ctx_t *hashcat_ctx, void *ptr, const size_t oldsz, cons
{
event_log_error (hashcat_ctx, "%s", MSG_ENOMEM);
exit (-1);
return (NULL);
}
memset ((char *) p + oldsz, 0, addsz);
@ -60,7 +60,9 @@ char *hcstrdup (hashcat_ctx_t *hashcat_ctx, const char *s)
char *b = (char *) hcmalloc (hashcat_ctx, len + 1);
strncpy (b, s, len);
if (b == NULL) return (NULL);
memcpy (b, s, len);
b[len] = 0;

View File

@ -69,12 +69,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));
int *fan_speed_chgd = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); VERIFY_PTR (fan_speed_chgd);
// temperature controller "loopback" values
int *temp_diff_old = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int));
int *temp_diff_sum = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int));
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);
time_t last_temp_check_time;

View File

@ -114,7 +114,7 @@ static void mp_css_split_cnt (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_orig
css_cnt_lr[1] = css_cnt_r;
}
static void mp_css_append_salt (hashcat_ctx_t *hashcat_ctx, salt_t *salt_buf)
static int mp_css_append_salt (hashcat_ctx_t *hashcat_ctx, salt_t *salt_buf)
{
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
@ -123,7 +123,7 @@ static void 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));
cs_t *css_buf_salt = (cs_t *) hccalloc (hashcat_ctx, css_cnt_salt, sizeof (cs_t)); VERIFY_PTR (css_buf_salt);
memcpy (css_buf_salt, mask_ctx->css_buf, mask_ctx->css_cnt * sizeof (cs_t));
@ -137,15 +137,17 @@ static void mp_css_append_salt (hashcat_ctx_t *hashcat_ctx, salt_t *salt_buf)
mask_ctx->css_buf = css_buf_salt;
mask_ctx->css_cnt = css_cnt_salt;
return 0;
}
static void mp_css_unicode_expand (hashcat_ctx_t *hashcat_ctx)
static int mp_css_unicode_expand (hashcat_ctx_t *hashcat_ctx)
{
mask_ctx_t *mask_ctx = hashcat_ctx->mask_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));
cs_t *css_buf_unicode = (cs_t *) hccalloc (hashcat_ctx, css_cnt_unicode, sizeof (cs_t)); VERIFY_PTR (css_buf_unicode);
for (u32 i = 0, j = 0; i < mask_ctx->css_cnt; i += 1, j += 2)
{
@ -159,6 +161,8 @@ static void mp_css_unicode_expand (hashcat_ctx_t *hashcat_ctx)
mask_ctx->css_buf = css_buf_unicode;
mask_ctx->css_cnt = css_cnt_unicode;
return 0;
}
static int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ])
@ -190,7 +194,7 @@ static int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *cs
return 0;
}
static void mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_len, cs_t *css, u32 css_cnt)
static int mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_len, cs_t *css, u32 css_cnt)
{
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
@ -198,7 +202,7 @@ static void mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_le
size_t css_uniq_sz = CHARSIZ * sizeof (u32);
u32 *css_uniq = (u32 *) hcmalloc (hashcat_ctx, css_uniq_sz);
u32 *css_uniq = (u32 *) hcmalloc (hashcat_ctx, css_uniq_sz); VERIFY_PTR (css_uniq);
size_t i;
@ -225,6 +229,8 @@ static void mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_le
}
hcfree (css_uniq);
return 0;
}
static int mp_expand (hashcat_ctx_t *hashcat_ctx, char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, u32 mp_usr_offset, int interpret)
@ -245,37 +251,41 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, char *in_buf, size_t in_len, c
u32 p1 = in_buf[in_pos] & 0xff;
int rc = 0;
switch (p1)
{
case 'l': mp_add_cs_buf (hashcat_ctx, mp_sys[0].cs_buf, mp_sys[0].cs_len, mp_usr, mp_usr_offset);
case 'l': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[0].cs_buf, mp_sys[0].cs_len, mp_usr, mp_usr_offset);
break;
case 'u': mp_add_cs_buf (hashcat_ctx, mp_sys[1].cs_buf, mp_sys[1].cs_len, mp_usr, mp_usr_offset);
case 'u': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[1].cs_buf, mp_sys[1].cs_len, mp_usr, mp_usr_offset);
break;
case 'd': mp_add_cs_buf (hashcat_ctx, mp_sys[2].cs_buf, mp_sys[2].cs_len, mp_usr, mp_usr_offset);
case 'd': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[2].cs_buf, mp_sys[2].cs_len, mp_usr, mp_usr_offset);
break;
case 's': mp_add_cs_buf (hashcat_ctx, mp_sys[3].cs_buf, mp_sys[3].cs_len, mp_usr, mp_usr_offset);
case 's': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[3].cs_buf, mp_sys[3].cs_len, mp_usr, mp_usr_offset);
break;
case 'a': mp_add_cs_buf (hashcat_ctx, mp_sys[4].cs_buf, mp_sys[4].cs_len, mp_usr, mp_usr_offset);
case 'a': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[4].cs_buf, mp_sys[4].cs_len, mp_usr, mp_usr_offset);
break;
case 'b': mp_add_cs_buf (hashcat_ctx, mp_sys[5].cs_buf, mp_sys[5].cs_len, mp_usr, mp_usr_offset);
case 'b': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[5].cs_buf, mp_sys[5].cs_len, mp_usr, mp_usr_offset);
break;
case '1': if (mp_usr[0].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 1 is undefined"); return -1; }
mp_add_cs_buf (hashcat_ctx, mp_usr[0].cs_buf, mp_usr[0].cs_len, mp_usr, mp_usr_offset);
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[0].cs_buf, mp_usr[0].cs_len, mp_usr, mp_usr_offset);
break;
case '2': if (mp_usr[1].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 2 is undefined"); return -1; }
mp_add_cs_buf (hashcat_ctx, mp_usr[1].cs_buf, mp_usr[1].cs_len, mp_usr, mp_usr_offset);
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[1].cs_buf, mp_usr[1].cs_len, mp_usr, mp_usr_offset);
break;
case '3': if (mp_usr[2].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 3 is undefined"); return -1; }
mp_add_cs_buf (hashcat_ctx, mp_usr[2].cs_buf, mp_usr[2].cs_len, mp_usr, mp_usr_offset);
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[2].cs_buf, mp_usr[2].cs_len, mp_usr, mp_usr_offset);
break;
case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 4 is undefined"); return -1; }
mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, mp_usr, mp_usr_offset);
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, mp_usr, mp_usr_offset);
break;
case '?': mp_add_cs_buf (hashcat_ctx, &p0, 1, mp_usr, mp_usr_offset);
case '?': rc = mp_add_cs_buf (hashcat_ctx, &p0, 1, mp_usr, mp_usr_offset);
break;
default: event_log_error (hashcat_ctx, "Syntax error: %s", in_buf);
return -1;
}
if (rc == -1) return -1;
}
else
{
@ -304,13 +314,17 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, char *in_buf, size_t in_len, c
chr = (u32) hex_convert ((u8) p1) << 0;
chr |= (u32) hex_convert ((u8) p0) << 4;
mp_add_cs_buf (hashcat_ctx, &chr, 1, mp_usr, mp_usr_offset);
const int rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, mp_usr, mp_usr_offset);
if (rc == -1) return -1;
}
else
{
u32 chr = p0;
mp_add_cs_buf (hashcat_ctx, &chr, 1, mp_usr, mp_usr_offset);
const int rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, mp_usr, mp_usr_offset);
if (rc == -1) return -1;
}
}
}
@ -318,12 +332,10 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, char *in_buf, size_t in_len, c
return 0;
}
static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u32 *css_cnt)
static int mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, cs_t *css_buf, u32 *css_cnt)
{
const user_options_t *user_options = hashcat_ctx->user_options;
cs_t *css = (cs_t *) hccalloc (hashcat_ctx, 256, sizeof (cs_t));
u32 mask_pos;
u32 css_pos;
@ -341,37 +353,41 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask
u32 chr = (u32) p1;
int rc = 0;
switch (p1)
{
case 'l': mp_add_cs_buf (hashcat_ctx, mp_sys[0].cs_buf, mp_sys[0].cs_len, css, css_pos);
case 'l': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[0].cs_buf, mp_sys[0].cs_len, css_buf, css_pos);
break;
case 'u': mp_add_cs_buf (hashcat_ctx, mp_sys[1].cs_buf, mp_sys[1].cs_len, css, css_pos);
case 'u': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[1].cs_buf, mp_sys[1].cs_len, css_buf, css_pos);
break;
case 'd': mp_add_cs_buf (hashcat_ctx, mp_sys[2].cs_buf, mp_sys[2].cs_len, css, css_pos);
case 'd': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[2].cs_buf, mp_sys[2].cs_len, css_buf, css_pos);
break;
case 's': mp_add_cs_buf (hashcat_ctx, mp_sys[3].cs_buf, mp_sys[3].cs_len, css, css_pos);
case 's': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[3].cs_buf, mp_sys[3].cs_len, css_buf, css_pos);
break;
case 'a': mp_add_cs_buf (hashcat_ctx, mp_sys[4].cs_buf, mp_sys[4].cs_len, css, css_pos);
case 'a': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[4].cs_buf, mp_sys[4].cs_len, css_buf, css_pos);
break;
case 'b': mp_add_cs_buf (hashcat_ctx, mp_sys[5].cs_buf, mp_sys[5].cs_len, css, css_pos);
case 'b': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[5].cs_buf, mp_sys[5].cs_len, css_buf, css_pos);
break;
case '1': if (mp_usr[0].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 1 is undefined"); return NULL; }
mp_add_cs_buf (hashcat_ctx, mp_usr[0].cs_buf, mp_usr[0].cs_len, css, css_pos);
case '1': if (mp_usr[0].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 1 is undefined"); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[0].cs_buf, mp_usr[0].cs_len, css_buf, css_pos);
break;
case '2': if (mp_usr[1].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 2 is undefined"); return NULL; }
mp_add_cs_buf (hashcat_ctx, mp_usr[1].cs_buf, mp_usr[1].cs_len, css, css_pos);
case '2': if (mp_usr[1].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 2 is undefined"); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[1].cs_buf, mp_usr[1].cs_len, css_buf, css_pos);
break;
case '3': if (mp_usr[2].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 3 is undefined"); return NULL; }
mp_add_cs_buf (hashcat_ctx, mp_usr[2].cs_buf, mp_usr[2].cs_len, css, css_pos);
case '3': if (mp_usr[2].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 3 is undefined"); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[2].cs_buf, mp_usr[2].cs_len, css_buf, css_pos);
break;
case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 4 is undefined"); return NULL; }
mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, css, css_pos);
case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 4 is undefined"); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, css_buf, css_pos);
break;
case '?': mp_add_cs_buf (hashcat_ctx, &chr, 1, css, css_pos);
case '?': rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, css_buf, css_pos);
break;
default: event_log_error (hashcat_ctx, "Syntax error: %s", mask_buf);
return NULL;
return -1;
}
if (rc == -1) return -1;
}
else
{
@ -385,7 +401,7 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask
{
event_log_error (hashcat_ctx, "The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf);
return NULL;
return -1;
}
char p1 = mask_buf[mask_pos];
@ -396,7 +412,7 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask
{
event_log_error (hashcat_ctx, "Invalid hex character detected in mask %s", mask_buf);
return NULL;
return -1;
}
u32 chr = 0;
@ -404,13 +420,17 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask
chr |= (u32) hex_convert ((u8) p1) << 0;
chr |= (u32) hex_convert ((u8) p0) << 4;
mp_add_cs_buf (hashcat_ctx, &chr, 1, css, css_pos);
const int rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, css_buf, css_pos);
if (rc == -1) return -1;
}
else
{
u32 chr = (u32) p0;
mp_add_cs_buf (hashcat_ctx, &chr, 1, css, css_pos);
const int rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, css_buf, css_pos);
if (rc == -1) return -1;
}
}
}
@ -419,20 +439,18 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask
{
event_log_error (hashcat_ctx, "Invalid mask length (0)");
return NULL;
return -1;
}
*css_cnt = css_pos;
return (css);
return 0;
}
static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask_buf, const size_t mask_len, const u32 len)
static int mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask_buf, const size_t mask_len, const u32 len, char *new_mask_buf)
{
const user_options_t *user_options = hashcat_ctx->user_options;
char *new_mask_buf = (char *) hcmalloc (hashcat_ctx, 256);
u32 mask_pos;
u32 css_pos;
@ -463,7 +481,7 @@ static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask
{
event_log_error (hashcat_ctx, "The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf);
return NULL;
return -1;
}
char p1 = mask_buf[mask_pos];
@ -474,7 +492,7 @@ static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask
{
event_log_error (hashcat_ctx, "Invalid hex character detected in mask: %s", mask_buf);
return NULL;
return -1;
}
new_mask_buf[mask_pos] = p1;
@ -482,11 +500,7 @@ static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask
}
}
if (css_pos == len) return (new_mask_buf);
hcfree (new_mask_buf);
return (NULL);
return 0;
}
static void mp_setup_sys (cs_t *mp_sys)
@ -587,7 +601,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));
u64 *root_stats_buf = (u64 *) hccalloc (hashcat_ctx, SP_ROOT_CNT, sizeof (u64)); VERIFY_PTR (root_stats_buf);
u64 *root_stats_ptr = root_stats_buf;
@ -600,7 +614,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));
u64 *markov_stats_buf = (u64 *) hccalloc (hashcat_ctx, SP_MARKOV_CNT, sizeof (u64)); VERIFY_PTR (markov_stats_buf);
u64 *markov_stats_ptr = markov_stats_buf;
@ -886,13 +900,13 @@ void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u
}
}
static void mask_append_final (hashcat_ctx_t *hashcat_ctx, const char *mask)
static int mask_append_final (hashcat_ctx_t *hashcat_ctx, const char *mask)
{
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
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 *));
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_avail += INCR_MASKS;
}
@ -900,9 +914,11 @@ static void mask_append_final (hashcat_ctx_t *hashcat_ctx, const char *mask)
mask_ctx->masks[mask_ctx->masks_cnt] = hcstrdup (hashcat_ctx, mask);
mask_ctx->masks_cnt++;
return 0;
}
static void mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask)
static int mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask)
{
user_options_t *user_options = hashcat_ctx->user_options;
@ -910,17 +926,25 @@ static void mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask)
{
for (u32 increment_len = user_options->increment_min; increment_len <= user_options->increment_max; increment_len++)
{
char *mask_truncated = mp_get_truncated_mask (hashcat_ctx, mask, strlen (mask), increment_len);
char *mask_truncated = (char *) hcmalloc (hashcat_ctx, 256); VERIFY_PTR (mask_truncated);
if (mask_truncated == NULL) break;
const int rc_truncated_mask = mp_get_truncated_mask (hashcat_ctx, mask, strlen (mask), increment_len, mask_truncated);
mask_append_final (hashcat_ctx, mask_truncated);
if (rc_truncated_mask == -1) break;
const int rc = mask_append_final (hashcat_ctx, mask_truncated);
if (rc == -1) return -1;
}
}
else
{
mask_append_final (hashcat_ctx, mask);
const int rc = mask_append_final (hashcat_ctx, mask);
if (rc == -1) return -1;
}
return 0;
}
int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx)
@ -948,9 +972,11 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx)
if (rc_mask_file == -1) return -1;
mask_ctx->css_buf = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, &mask_ctx->css_cnt);
mask_ctx->css_buf = (cs_t *) hccalloc (hashcat_ctx, 256, sizeof (cs_t)); VERIFY_PTR (mask_ctx->css_buf);
if (mask_ctx->css_buf == NULL) return -1;
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);
if (rc_gen_css == -1) return -1;
u32 uniq_tbls[SP_PW_MAX][CHARSIZ] = { { 0 } };
@ -979,9 +1005,11 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx)
if (user_options->attack_mode == ATTACK_MODE_BF) // always true
{
mask_ctx->css_buf = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, &mask_ctx->css_cnt);
mask_ctx->css_buf = (cs_t *) hccalloc (hashcat_ctx, 256, sizeof (cs_t)); VERIFY_PTR (mask_ctx->css_buf);
if (mask_ctx->css_buf == NULL) return -1;
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);
if (rc_gen_css == -1) return -1;
// special case for benchmark
@ -1029,7 +1057,9 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->opts_type & OPTS_TYPE_PT_UNICODE)
{
mp_css_unicode_expand (hashcat_ctx);
const int rc = mp_css_unicode_expand (hashcat_ctx);
if (rc == -1) return -1;
}
u32 css_cnt_orig = mask_ctx->css_cnt;
@ -1038,7 +1068,9 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx)
{
if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT)
{
mp_css_append_salt (hashcat_ctx, &hashes->salts_buf[0]);
const int rc = mp_css_append_salt (hashcat_ctx, &hashes->salts_buf[0]);
if (rc == -1) return -1;
}
}
@ -1086,13 +1118,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));
mask_ctx->markov_table_buf = (hcstat_table_t *) hccalloc (hashcat_ctx, SP_MARKOV_CNT, sizeof (hcstat_table_t));
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);
sp_setup_tbl (hashcat_ctx);
mask_ctx->root_css_buf = (cs_t *) hccalloc (hashcat_ctx, SP_PW_MAX, sizeof (cs_t));
mask_ctx->markov_css_buf = (cs_t *) hccalloc (hashcat_ctx, SP_PW_MAX * CHARSIZ, sizeof (cs_t));
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->css_cnt = 0;
mask_ctx->css_buf = NULL;
@ -1103,7 +1135,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));
mask_ctx->mfs = (mf_t *) hccalloc (hashcat_ctx, MAX_MFS, sizeof (mf_t)); VERIFY_PTR (mask_ctx->mfs);
mp_setup_sys (mask_ctx->mp_sys);
@ -1124,7 +1156,9 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (stat (arg, &file_stat) == -1)
{
mask_append (hashcat_ctx, arg);
const int rc = mask_append (hashcat_ctx, arg);
if (rc == -1) return -1;
}
else
{
@ -1152,7 +1186,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
return -1;
}
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf);
while (!feof (mask_fp))
{
@ -1162,7 +1196,9 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (line_buf[0] == '#') continue;
mask_append (hashcat_ctx, line_buf);
const int rc = mask_append (hashcat_ctx, line_buf);
if (rc == -1) return -1;
}
hcfree (line_buf);
@ -1182,14 +1218,18 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
{
const char *mask = DEF_MASK;
mask_append (hashcat_ctx, mask);
const int rc = mask_append (hashcat_ctx, mask);
if (rc == -1) return -1;
}
}
else
{
const char *mask = hashconfig_benchmark_mask (hashcat_ctx);
mask_append (hashcat_ctx, mask);
const int rc = mask_append (hashcat_ctx, mask);
if (rc == -1) return -1;
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
@ -1204,7 +1244,9 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (stat (arg, &file_stat) == -1)
{
mask_append (hashcat_ctx, arg);
const int rc = mask_append (hashcat_ctx, arg);
if (rc == -1) return -1;
}
else
{
@ -1221,7 +1263,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
return -1;
}
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf);
while (!feof (mask_fp))
{
@ -1231,7 +1273,9 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (line_buf[0] == '#') continue;
mask_append (hashcat_ctx, line_buf);
const int rc = mask_append (hashcat_ctx, line_buf);
if (rc == -1) return -1;
}
hcfree (line_buf);
@ -1258,7 +1302,9 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (stat (arg, &file_stat) == -1)
{
mask_append (hashcat_ctx, arg);
const int rc = mask_append (hashcat_ctx, arg);
if (rc == -1) return -1;
}
else
{
@ -1275,7 +1321,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
return -1;
}
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf);
while (!feof (mask_fp))
{
@ -1285,7 +1331,9 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (line_buf[0] == '#') continue;
mask_append (hashcat_ctx, line_buf);
const int rc = mask_append (hashcat_ctx, line_buf);
if (rc == -1) return -1;
}
hcfree (line_buf);

View File

@ -224,7 +224,7 @@ static int read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_fi
stat (kernel_file, &st);
char *buf = (char *) hcmalloc (hashcat_ctx, st.st_size + 1);
char *buf = (char *) hcmalloc (hashcat_ctx, st.st_size + 1); VERIFY_PTR (buf);
size_t num_read = fread (buf, sizeof (char), st.st_size, fp);
@ -1891,7 +1891,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));
hc_device_param_t *devices_param = (hc_device_param_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hc_device_param_t)); VERIFY_PTR (devices_param);
opencl_ctx->devices_param = devices_param;
@ -1899,7 +1899,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));
OCL_PTR *ocl = (OCL_PTR *) hcmalloc (hashcat_ctx, sizeof (OCL_PTR)); VERIFY_PTR (ocl);
opencl_ctx->ocl = ocl;
@ -1948,9 +1948,9 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx)
*/
cl_uint platforms_cnt = 0;
cl_platform_id *platforms = (cl_platform_id *) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (cl_platform_id));
cl_platform_id *platforms = (cl_platform_id *) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (cl_platform_id)); VERIFY_PTR (platforms);
cl_uint platform_devices_cnt = 0;
cl_device_id *platform_devices = (cl_device_id *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (cl_device_id));
cl_device_id *platform_devices = (cl_device_id *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (cl_device_id)); VERIFY_PTR (platform_devices);
cl_int CL_err = hc_clGetPlatformIDs (hashcat_ctx, CL_PLATFORMS_MAX, platforms, &platforms_cnt);
@ -2245,7 +2245,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
if (CL_err == -1) return -1;
char *device_name = (char *) hcmalloc (hashcat_ctx, param_value_size);
char *device_name = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_name);
CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NAME, param_value_size, device_name, NULL);
@ -2259,7 +2259,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
if (CL_err == -1) return -1;
char *device_vendor = (char *) hcmalloc (hashcat_ctx, param_value_size);
char *device_vendor = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_vendor);
CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VENDOR, param_value_size, device_vendor, NULL);
@ -2314,7 +2314,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
if (CL_err == -1) return -1;
char *device_version = (char *) hcmalloc (hashcat_ctx, param_value_size);
char *device_version = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_version);
CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VERSION, param_value_size, device_version, NULL);
@ -2328,7 +2328,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
if (CL_err == -1) return -1;
char *device_opencl_version = (char *) hcmalloc (hashcat_ctx, param_value_size);
char *device_opencl_version = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_opencl_version);
CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_OPENCL_C_VERSION, param_value_size, device_opencl_version, NULL);
@ -2455,7 +2455,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
if (CL_err == -1) return -1;
char *device_extensions = hcmalloc (hashcat_ctx, device_extensions_size + 1);
char *device_extensions = hcmalloc (hashcat_ctx, device_extensions_size + 1); VERIFY_PTR (device_extensions);
CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_EXTENSIONS, device_extensions_size, device_extensions, NULL);
@ -2523,7 +2523,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
if (CL_err == -1) return -1;
char *driver_version = (char *) hcmalloc (hashcat_ctx, param_value_size);
char *driver_version = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (driver_version);
CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DRIVER_VERSION, param_value_size, driver_version, NULL);
@ -2533,7 +2533,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);
char *device_name_chksum = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (device_name_chksum);
#if defined (__x86_64__)
snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%u-%u-%u-%s-%s-%s-%u", 64, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, comptime);
@ -3499,9 +3499,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));
size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); VERIFY_PTR (kernel_lengths);
char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *));
char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); VERIFY_PTR (kernel_sources);
if (opencl_ctx->force_jit_compilation == -1)
{
@ -3533,7 +3533,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (CL_err != CL_SUCCESS)
#endif
{
char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1);
char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log);
CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL);
@ -3559,7 +3559,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (CL_err == -1) return -1;
char *binary = (char *) hcmalloc (hashcat_ctx, binary_size);
char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); VERIFY_PTR (binary);
CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL);
@ -3635,7 +3635,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (CL_err != CL_SUCCESS)
#endif
{
char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1);
char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log);
CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL);
@ -3703,9 +3703,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));
size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); VERIFY_PTR (kernel_lengths);
char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *));
char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); VERIFY_PTR (kernel_sources);
if (cached == 0)
{
@ -3736,7 +3736,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (CL_err != CL_SUCCESS)
#endif
{
char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1);
char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log);
CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL);
@ -3762,7 +3762,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (CL_err == -1) return -1;
char *binary = (char *) hcmalloc (hashcat_ctx, binary_size);
char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); VERIFY_PTR (binary);
CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL);
@ -3844,9 +3844,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));
size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); VERIFY_PTR (kernel_lengths);
char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *));
char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); VERIFY_PTR (kernel_sources);
if (cached == 0)
{
@ -3877,7 +3877,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (CL_err != CL_SUCCESS)
#endif
{
char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1);
char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log);
CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL);
@ -3903,7 +3903,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (CL_err == -1) return -1;
char *binary = (char *) hcmalloc (hashcat_ctx, binary_size);
char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); VERIFY_PTR (binary);
CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL);
@ -4048,15 +4048,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
* main host data
*/
pw_t *pws_buf = (pw_t *) hcmalloc (hashcat_ctx, size_pws);
pw_t *pws_buf = (pw_t *) hcmalloc (hashcat_ctx, size_pws); VERIFY_PTR (pws_buf);
device_param->pws_buf = pws_buf;
comb_t *combs_buf = (comb_t *) hccalloc (hashcat_ctx, KERNEL_COMBS, sizeof (comb_t));
comb_t *combs_buf = (comb_t *) hccalloc (hashcat_ctx, KERNEL_COMBS, sizeof (comb_t)); VERIFY_PTR (combs_buf);
device_param->combs_buf = combs_buf;
void *hooks_buf = hcmalloc (hashcat_ctx, size_hooks);
void *hooks_buf = hcmalloc (hashcat_ctx, size_hooks); VERIFY_PTR (hooks_buf);
device_param->hooks_buf = hooks_buf;

View File

@ -16,7 +16,7 @@
#include "shared.h"
#include "thread.h"
static void outfile_remove (hashcat_ctx_t *hashcat_ctx)
static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
{
// some hash-dependent constants
@ -38,10 +38,10 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx)
// buffers
hash_t hash_buf = { 0, 0, 0, 0, 0 };
hash_buf.digest = hcmalloc (hashcat_ctx, dgst_size);
hash_buf.digest = hcmalloc (hashcat_ctx, dgst_size); VERIFY_PTR (hash_buf.digest);
if (is_salted) hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t));
if (esalt_size) hash_buf.esalt = (void *) hcmalloc (hashcat_ctx, esalt_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);
u32 digest_buf[64] = { 0 };
@ -83,7 +83,7 @@ static void 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));
out_info_new = (outfile_data_t *) hccalloc (hashcat_ctx, out_cnt_new, sizeof (outfile_data_t)); VERIFY_PTR (out_info_new);
for (int i = 0; i < out_cnt_new; i++)
{
@ -146,7 +146,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx)
fseek (fp, out_info[j].seek, SEEK_SET);
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf);
while (!feof (fp))
{
@ -307,13 +307,17 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx)
hcfree (out_info);
hcfree (out_files);
return 0;
}
void *thread_outfile_remove (void *p)
{
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) p;
outfile_remove (hashcat_ctx);
const int rc = outfile_remove (hashcat_ctx);
if (rc == -1) return NULL;
return NULL;
}
@ -339,7 +343,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);
outcheck_ctx->root_directory = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (outcheck_ctx->root_directory);
snprintf (outcheck_ctx->root_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", folder_config->session_dir, user_options->session, OUTFILES_DIR);
}

View File

@ -164,14 +164,14 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->potfile_path == NULL)
{
potfile_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY);
potfile_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (potfile_ctx->filename);
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);
potfile_ctx->filename = hcstrdup (hashcat_ctx, user_options->potfile_path); VERIFY_PTR (potfile_ctx->filename);
potfile_ctx->fp = NULL;
}
@ -216,22 +216,22 @@ int potfile_read_open (hashcat_ctx_t *hashcat_ctx)
return 0;
}
void potfile_read_parse (hashcat_ctx_t *hashcat_ctx)
int potfile_read_parse (hashcat_ctx_t *hashcat_ctx)
{
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
if (potfile_ctx->enabled == false) return;
if (potfile_ctx->enabled == false) return 0;
if (potfile_ctx->fp == NULL) return;
if (potfile_ctx->fp == NULL) return 0;
potfile_ctx->pot_avail = count_lines (hashcat_ctx, potfile_ctx->fp);
potfile_ctx->pot = (pot_t *) hccalloc (hashcat_ctx, potfile_ctx->pot_avail, sizeof (pot_t));
potfile_ctx->pot = (pot_t *) hccalloc (hashcat_ctx, potfile_ctx->pot_avail, sizeof (pot_t)); VERIFY_PTR (potfile_ctx->pot);
rewind (potfile_ctx->fp);
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf);
for (u32 line_num = 0; line_num < potfile_ctx->pot_avail; line_num++)
{
@ -246,7 +246,9 @@ void potfile_read_parse (hashcat_ctx_t *hashcat_ctx)
if (potfile_ctx->pot_cnt == potfile_ctx->pot_hashes_avail)
{
potfile_hash_alloc (hashcat_ctx, INCR_POT);
const int rc = potfile_hash_alloc (hashcat_ctx, INCR_POT);
if (rc == -1) return -1;
}
int parser_status;
@ -324,6 +326,8 @@ void potfile_read_parse (hashcat_ctx_t *hashcat_ctx)
hcfree (line_buf);
hc_qsort_r (potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
return 0;
}
void potfile_read_close (hashcat_ctx_t *hashcat_ctx)
@ -418,12 +422,12 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *
fflush (potfile_ctx->fp);
}
void potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num)
int potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num)
{
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
if (potfile_ctx->enabled == false) return;
if (potfile_ctx->enabled == false) return 0;
u32 pos = 0;
@ -435,20 +439,22 @@ void potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num)
hash_t *tmp_hash = &tmp_pot->hash;
tmp_hash->digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size);
tmp_hash->digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size); VERIFY_PTR (tmp_hash->digest);
if (hashconfig->is_salted)
{
tmp_hash->salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t));
tmp_hash->salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); VERIFY_PTR (tmp_hash->salt);
}
if (hashconfig->esalt_size)
{
tmp_hash->esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size);
tmp_hash->esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size); VERIFY_PTR (tmp_hash->esalt);
}
potfile_ctx->pot_hashes_avail++;
}
return 0;
}
void potfile_hash_free (hashcat_ctx_t *hashcat_ctx)
@ -553,12 +559,12 @@ void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int inpu
}
}
void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *))
int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *))
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return;
if (potfile_ctx->enabled == false) return 0;
// left
@ -588,11 +594,12 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i
{
weak_hash_found = 1;
pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t));
pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); VERIFY_PTR (pot_right_ptr);
// in theory this is not needed, but we are paranoia:
memset (pot_right_ptr->plain_buf, 0, sizeof (pot_right_ptr->plain_buf));
pot_right_ptr->plain_len = 0;
}
}
@ -601,7 +608,7 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i
{
if (weak_hash_found == 1) hcfree (pot_right_ptr); // this shouldn't happen at all: if weak_hash_found == 1, than pot_right_ptr is not NULL for sure
return;
return 0;
}
// at least one half was found:
@ -613,6 +620,7 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i
// user
unsigned char *username = NULL;
u32 user_len = 0;
if (hash_left->hash_info)
@ -638,11 +646,12 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i
{
left_part_masked = 1;
pot_left_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t));
pot_left_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); VERIFY_PTR (pot_left_ptr);
memset (pot_left_ptr->plain_buf, 0, sizeof (pot_left_ptr->plain_buf));
memcpy (pot_left_ptr->plain_buf, LM_MASKED_PLAIN, mask_plain_len);
pot_left_ptr->plain_len = mask_plain_len;
}
@ -650,11 +659,12 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i
{
right_part_masked = 1;
pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t));
pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); VERIFY_PTR (pot_right_ptr);
memset (pot_right_ptr->plain_buf, 0, sizeof (pot_right_ptr->plain_buf));
memcpy (pot_right_ptr->plain_buf, LM_MASKED_PLAIN, mask_plain_len);
pot_right_ptr->plain_len = mask_plain_len;
}
@ -680,14 +690,16 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i
if (left_part_masked == 1) hcfree (pot_left_ptr);
if (right_part_masked == 1) hcfree (pot_right_ptr);
return 0;
}
void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *))
int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *))
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return;
if (potfile_ctx->enabled == false) return 0;
// left
@ -717,7 +729,7 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i
// we just need that pot_right_ptr is not a NULL pointer
pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t));
pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); VERIFY_PTR (pot_right_ptr);
}
}
@ -725,7 +737,7 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i
{
if (weak_hash_found == 1) hcfree (pot_right_ptr);
return;
return 0;
}
// ... at least one part was not cracked
@ -738,7 +750,7 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i
u32 user_len = (u32)input_len - 32u;
char *hash_output = (char *) hcmalloc (hashcat_ctx, 33);
char *hash_output = (char *) hcmalloc (hashcat_ctx, 33); VERIFY_PTR (hash_output);
memcpy (hash_output, input_buf, input_len);
@ -769,31 +781,33 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i
hcfree (hash_output);
if (weak_hash_found == 1) hcfree (pot_right_ptr);
return 0;
}
void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
hashes_t *hashes = hashcat_ctx->hashes;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return;
if (potfile_ctx->enabled == false) return 0;
hash_t *hashes_buf = hashes->hashes_buf;
u32 hashes_cnt = hashes->hashes_cnt;
// no solution for these special hash types (for instane because they use hashfile in output etc)
if (hashconfig->hash_mode == 5200) return;
if (hashconfig->hash_mode == 5200) return 0;
if ((hashconfig->hash_mode >= 6200)
&& (hashconfig->hash_mode <= 6299)) return;
if (hashconfig->hash_mode == 9000) return;
&& (hashconfig->hash_mode <= 6299)) return 0;
if (hashconfig->hash_mode == 9000) return 0;
if ((hashconfig->hash_mode >= 13700)
&& (hashconfig->hash_mode <= 13799)) return;
&& (hashconfig->hash_mode <= 13799)) return 0;
hash_t hash_buf;
hash_buf.digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size);
hash_buf.digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size); VERIFY_PTR (hash_buf.digest);
hash_buf.salt = NULL;
hash_buf.esalt = NULL;
hash_buf.hash_info = NULL;
@ -801,25 +815,25 @@ void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->is_salted)
{
hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t));
hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); VERIFY_PTR (hash_buf.salt);
}
if (hashconfig->esalt_size)
{
hash_buf.esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size);
hash_buf.esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size); VERIFY_PTR (hash_buf.esalt);
}
const int rc = potfile_read_open (hashcat_ctx);
if (rc == -1) return;
if (rc == -1) return -1;
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf);
// 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);
char *line_buf_cpy = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf_cpy);
while (!feof (potfile_ctx->fp))
{
@ -973,4 +987,6 @@ void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
}
hcfree (hash_buf.digest);
return 0;
}

View File

@ -62,7 +62,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));
restore_data_t *rd = (restore_data_t *) hcmalloc (hashcat_ctx, sizeof (restore_data_t)); VERIFY_PTR (rd);
const size_t nread = fread (rd, sizeof (restore_data_t), 1, fp);
@ -77,7 +77,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx)
if (rd->pid)
{
char *pidbin = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
char *pidbin = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin);
int pidbin_len = -1;
@ -113,7 +113,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx)
#elif defined (_WIN)
HANDLE hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, rd->pid);
char *pidbin2 = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
char *pidbin2 = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin2);
int pidbin2_len = -1;
@ -156,7 +156,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));
restore_data_t *rd = (restore_data_t *) hcmalloc (hashcat_ctx, sizeof (restore_data_t)); VERIFY_PTR (rd);
restore_ctx->rd = rd;
@ -211,9 +211,9 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
return -1;
}
rd->argv = (char **) hccalloc (hashcat_ctx, rd->argc, sizeof (char *));
rd->argv = (char **) hccalloc (hashcat_ctx, rd->argc, sizeof (char *)); VERIFY_PTR (rd->argv);
char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (buf);
for (u32 i = 0; i < rd->argc; i++)
{
@ -395,8 +395,8 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
restore_ctx->enabled = false;
char *eff_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY);
char *new_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY);
char *eff_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (eff_restore_file);
char *new_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (new_restore_file);
snprintf (eff_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore", folder_config->session_dir, user_options->session);
snprintf (new_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore.new", folder_config->session_dir, user_options->session);

View File

@ -728,12 +728,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));
all_kernel_rules_cnt = (u32 *) hccalloc (hashcat_ctx, user_options->rp_files_cnt, sizeof (u32)); VERIFY_PTR (all_kernel_rules_cnt);
all_kernel_rules_buf = (kernel_rule_t **) hccalloc (hashcat_ctx, user_options->rp_files_cnt, sizeof (kernel_rule_t *));
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);
}
char *rule_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
char *rule_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (rule_buf);
int rule_len = 0;
@ -773,7 +773,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));
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_avail += INCR_RULES;
}
@ -816,7 +816,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));
u32 *repeats = (u32 *) hccalloc (hashcat_ctx, user_options->rp_files_cnt + 1, sizeof (u32)); VERIFY_PTR (repeats);
repeats[0] = kernel_rules_cnt;
@ -827,7 +827,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));
kernel_rule_t *kernel_rules_buf = (kernel_rule_t *) hccalloc (hashcat_ctx, kernel_rules_cnt, sizeof (kernel_rule_t)); VERIFY_PTR (kernel_rules_buf);
for (u32 i = 0; i < kernel_rules_cnt; i++)
{
@ -879,9 +879,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));
kernel_rule_t *kernel_rules_buf = hccalloc (hashcat_ctx, user_options->rp_gen, sizeof (kernel_rule_t)); VERIFY_PTR (kernel_rules_buf);
char *rule_buf = (char *) hcmalloc (hashcat_ctx, RP_RULE_BUFSIZ);
char *rule_buf = (char *) hcmalloc (hashcat_ctx, RP_RULE_BUFSIZ); VERIFY_PTR (rule_buf);
for (kernel_rules_cnt = 0; kernel_rules_cnt < user_options->rp_gen; kernel_rules_cnt++)
{

View File

@ -1347,9 +1347,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));
status_ctx->words_progress_rejected = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64));
status_ctx->words_progress_restored = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64));
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);
return 0;
}

View File

@ -20,20 +20,22 @@
#include "straight.h"
#include "wordlist.h"
static void straight_ctx_add_wl (hashcat_ctx_t *hashcat_ctx, const char *dict)
static int straight_ctx_add_wl (hashcat_ctx_t *hashcat_ctx, const char *dict)
{
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
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 *));
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_avail += INCR_DICTS;
}
straight_ctx->dicts[straight_ctx->dicts_cnt] = hcstrdup (hashcat_ctx, dict);
straight_ctx->dicts[straight_ctx->dicts_cnt] = hcstrdup (hashcat_ctx, dict); VERIFY_PTR (straight_ctx->dicts[straight_ctx->dicts_cnt]);
straight_ctx->dicts_cnt++;
return 0;
}
int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx)
@ -198,7 +200,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));
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[0].cmds[0] = RULE_OP_MANGLE_NOOP;
@ -304,7 +306,9 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (S_ISREG (l1_stat.st_mode))
{
straight_ctx_add_wl (hashcat_ctx, l1_filename);
const int rc = straight_ctx_add_wl (hashcat_ctx, l1_filename);
if (rc == -1) return -1;
}
}
}
@ -313,7 +317,9 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
}
else
{
straight_ctx_add_wl (hashcat_ctx, l0_filename);
const int rc = straight_ctx_add_wl (hashcat_ctx, l0_filename);
if (rc == -1) return -1;
}
}
@ -373,7 +379,9 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (S_ISREG (l1_stat.st_mode))
{
straight_ctx_add_wl (hashcat_ctx, l1_filename);
const int rc = straight_ctx_add_wl (hashcat_ctx, l1_filename);
if (rc == -1) return -1;
}
}
}
@ -382,7 +390,9 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
}
else
{
straight_ctx_add_wl (hashcat_ctx, l0_filename);
const int rc = straight_ctx_add_wl (hashcat_ctx, l0_filename);
if (rc == -1) return -1;
}
}
@ -433,7 +443,9 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (S_ISREG (l1_stat.st_mode))
{
straight_ctx_add_wl (hashcat_ctx, l1_filename);
const int rc = straight_ctx_add_wl (hashcat_ctx, l1_filename);
if (rc == -1) return -1;
}
}
}
@ -442,7 +454,9 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
}
else
{
straight_ctx_add_wl (hashcat_ctx, l0_filename);
const int rc = straight_ctx_add_wl (hashcat_ctx, l0_filename);
if (rc == -1) return -1;
}
}

View File

@ -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);
char *tuning_db_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (tuning_db_file);
snprintf (tuning_db_file, HCBUFSIZ_TINY - 1, "%s/%s", folder_config->shared_dir, TUNING_DB_FILE);
@ -86,17 +86,17 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
// a bit over-allocated
tuning_db->alias_buf = (tuning_db_alias_t *) hccalloc (hashcat_ctx, num_lines + 1, sizeof (tuning_db_alias_t));
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_cnt = 0;
tuning_db->entry_buf = (tuning_db_entry_t *) hccalloc (hashcat_ctx, num_lines + 1, sizeof (tuning_db_entry_t));
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_cnt = 0;
rewind (fp);
int line_num = 0;
char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (buf);
while (!feof (fp))
{

View File

@ -108,7 +108,7 @@ static char DEF_MASK_CS_1[] = "?l?d?u";
static char DEF_MASK_CS_2[] = "?l?d";
static char DEF_MASK_CS_3[] = "?l?d*!$@_";
void user_options_init (hashcat_ctx_t *hashcat_ctx)
int user_options_init (hashcat_ctx_t *hashcat_ctx)
{
user_options_t *user_options = hashcat_ctx->user_options;
@ -192,10 +192,12 @@ void 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 *));
user_options->rp_files = (char **) hccalloc (hashcat_ctx, 256, sizeof (char *)); VERIFY_PTR (user_options->rp_files);
user_options->hc_bin = PROGNAME;
user_options->hc_argc = 0;
user_options->hc_argv = NULL;
return 0;
}
void user_options_destroy (hashcat_ctx_t *hashcat_ctx)

View File

@ -58,7 +58,7 @@ u32 convert_from_hex (hashcat_ctx_t *hashcat_ctx, char *line_buf, const u32 line
return (line_len);
}
void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd)
int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd)
{
wl_data_t *wl_data = hashcat_ctx->wl_data;
@ -70,15 +70,15 @@ void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd)
wl_data->buf[wl_data->cnt] = 0;
if (wl_data->cnt == 0) return;
if (wl_data->cnt == 0) return 0;
if (wl_data->buf[wl_data->cnt - 1] == '\n') return;
if (wl_data->buf[wl_data->cnt - 1] == '\n') return 0;
while (!feof (fd))
{
if (wl_data->cnt == wl_data->avail)
{
wl_data->buf = (char *) hcrealloc (hashcat_ctx, wl_data->buf, wl_data->avail, wl_data->incr);
wl_data->buf = (char *) hcrealloc (hashcat_ctx, wl_data->buf, wl_data->avail, wl_data->incr); VERIFY_PTR (wl_data->buf);
wl_data->avail += wl_data->incr;
}
@ -103,7 +103,7 @@ void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd)
wl_data->buf[wl_data->cnt - 1] = '\n';
}
return;
return 0;
}
void get_next_word_lm (char *buf, u64 sz, u64 *len, u64 *off)
@ -414,7 +414,7 @@ u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile)
return (cnt);
}
void wl_data_init (hashcat_ctx_t *hashcat_ctx)
int wl_data_init (hashcat_ctx_t *hashcat_ctx)
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
user_options_t *user_options = hashcat_ctx->user_options;
@ -422,16 +422,16 @@ void wl_data_init (hashcat_ctx_t *hashcat_ctx)
wl_data->enabled = false;
if (user_options->benchmark == true) return;
if (user_options->keyspace == true) return;
if (user_options->left == true) return;
if (user_options->opencl_info == true) return;
if (user_options->usage == true) return;
if (user_options->version == true) return;
if (user_options->benchmark == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->opencl_info == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
wl_data->enabled = true;
wl_data->buf = (char *) hcmalloc (hashcat_ctx, user_options->segment_size);
wl_data->buf = (char *) hcmalloc (hashcat_ctx, user_options->segment_size); VERIFY_PTR (wl_data->buf);
wl_data->avail = user_options->segment_size;
wl_data->incr = user_options->segment_size;
wl_data->cnt = 0;
@ -452,6 +452,8 @@ void wl_data_init (hashcat_ctx_t *hashcat_ctx)
{
wl_data->func = get_next_word_lm;
}
return 0;
}
void wl_data_destroy (hashcat_ctx_t *hashcat_ctx)