1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-22 08:08:10 +00:00

Merge pull request #1808 from Naufragous/fix-snprintf

Correct buffer size parameter in snprintf calls
This commit is contained in:
Jens Steube 2018-12-09 20:38:57 +01:00 committed by GitHub
commit 050b54b8cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 241 additions and 241 deletions

View File

@ -921,7 +921,7 @@ bool brain_client_connect (hc_device_param_t *device_param, const status_ctx_t *
char port_str[8]; char port_str[8];
snprintf (port_str, sizeof (port_str) - 1, "%i", port); snprintf (port_str, sizeof (port_str), "%i", port);
const char *host_real = (host == NULL) ? "127.0.0.1" : (const char *) host; const char *host_real = (host == NULL) ? "127.0.0.1" : (const char *) host;
@ -1563,7 +1563,7 @@ bool brain_server_write_hash_dumps (brain_server_dbs_t *brain_server_dbs, const
char file[100]; char file[100];
snprintf (file, sizeof (file) - 1, "%s/brain.%08x.ldmp", path, brain_server_db_hash->brain_session); snprintf (file, sizeof (file), "%s/brain.%08x.ldmp", path, brain_server_db_hash->brain_session);
brain_server_write_hash_dump (brain_server_db_hash, file); brain_server_write_hash_dump (brain_server_db_hash, file);
@ -1762,7 +1762,7 @@ bool brain_server_write_attack_dumps (brain_server_dbs_t *brain_server_dbs, cons
char file[100]; char file[100];
snprintf (file, sizeof (file) - 1, "%s/brain.%08x.admp", path, brain_server_db_attack->brain_attack); snprintf (file, sizeof (file), "%s/brain.%08x.admp", path, brain_server_db_attack->brain_attack);
brain_server_write_attack_dump (brain_server_db_attack, file); brain_server_write_attack_dump (brain_server_db_attack, file);
@ -2972,7 +2972,7 @@ int brain_server (const char *listen_host, const int listen_port, const char *br
auth_password = (char *) hcmalloc (BRAIN_PASSWORD_SZ); auth_password = (char *) hcmalloc (BRAIN_PASSWORD_SZ);
snprintf (auth_password, BRAIN_PASSWORD_SZ - 1, "%08x%08x", brain_auth_challenge (), brain_auth_challenge ()); snprintf (auth_password, BRAIN_PASSWORD_SZ, "%08x%08x", brain_auth_challenge (), brain_auth_challenge ());
brain_logging (stdout, 0, "Generated authentication password: %s\n", auth_password); brain_logging (stdout, 0, "Generated authentication password: %s\n", auth_password);
} }

View File

@ -100,12 +100,12 @@ static void get_install_dir (char *install_dir, const char *exec_path)
#if defined (_POSIX) #if defined (_POSIX)
static void get_profile_dir (char *profile_dir, const char *home_dir) static void get_profile_dir (char *profile_dir, const char *home_dir)
{ {
snprintf (profile_dir, HCBUFSIZ_TINY - 1, "%s/%s", home_dir, DOT_HASHCAT); snprintf (profile_dir, HCBUFSIZ_TINY, "%s/%s", home_dir, DOT_HASHCAT);
} }
static void get_session_dir (char *session_dir, const char *profile_dir) static void get_session_dir (char *session_dir, const char *profile_dir)
{ {
snprintf (session_dir, HCBUFSIZ_TINY - 1, "%s/%s", profile_dir, SESSIONS_FOLDER); snprintf (session_dir, HCBUFSIZ_TINY, "%s/%s", profile_dir, SESSIONS_FOLDER);
} }
#endif #endif

View File

@ -71,7 +71,7 @@ static char *hm_SYSFS_get_syspath_hwmon (hashcat_ctx_t *hashcat_ctx, const int d
char *hwmon = hcmalloc (HCBUFSIZ_TINY); char *hwmon = hcmalloc (HCBUFSIZ_TINY);
snprintf (hwmon, HCBUFSIZ_TINY - 1, "%s/hwmon", syspath); snprintf (hwmon, HCBUFSIZ_TINY, "%s/hwmon", syspath);
char *hwmonN = first_file_in_directory (hwmon); char *hwmonN = first_file_in_directory (hwmon);
@ -87,7 +87,7 @@ static char *hm_SYSFS_get_syspath_hwmon (hashcat_ctx_t *hashcat_ctx, const int d
return NULL; return NULL;
} }
snprintf (hwmon, HCBUFSIZ_TINY - 1, "%s/hwmon/%s", syspath, hwmonN); snprintf (hwmon, HCBUFSIZ_TINY, "%s/hwmon/%s", syspath, hwmonN);
hcfree (syspath); hcfree (syspath);

File diff suppressed because it is too large Load Diff

View File

@ -4889,9 +4889,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
char build_opts_base[1024] = { 0 }; char build_opts_base[1024] = { 0 };
#if defined (_WIN) #if defined (_WIN)
snprintf (build_opts_base, sizeof (build_opts_base) - 1, "-cl-std=CL1.2 -I OpenCL -I \"%s\"", folder_config->cpath_real); snprintf (build_opts_base, sizeof (build_opts_base), "-cl-std=CL1.2 -I OpenCL -I \"%s\"", folder_config->cpath_real);
#else #else
snprintf (build_opts_base, sizeof (build_opts_base) - 1, "-cl-std=CL1.2 -I OpenCL -I %s", folder_config->cpath_real); snprintf (build_opts_base, sizeof (build_opts_base), "-cl-std=CL1.2 -I OpenCL -I %s", folder_config->cpath_real);
#endif #endif
// we don't have sm_* on vendors not NV but it doesn't matter // we don't have sm_* on vendors not NV but it doesn't matter
@ -4899,9 +4899,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
char build_opts[2048] = { 0 }; char build_opts[2048] = { 0 };
#if defined (DEBUG) #if defined (DEBUG)
snprintf (build_opts, sizeof (build_opts) - 1, "%s -D LOCAL_MEM_TYPE=%u -D VENDOR_ID=%u -D CUDA_ARCH=%u -D AMD_ROCM=%u -D VECT_SIZE=%u -D DEVICE_TYPE=%u -D DGST_R0=%u -D DGST_R1=%u -D DGST_R2=%u -D DGST_R3=%u -D DGST_ELEM=%u -D KERN_TYPE=%u -D _unroll", build_opts_base, device_param->device_local_mem_type, device_param->platform_vendor_id, (device_param->sm_major * 100) + device_param->sm_minor, device_param->is_rocm, device_param->vector_width, (u32) device_param->device_type, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, hashconfig->dgst_size / 4, hashconfig->kern_type); snprintf (build_opts, sizeof (build_opts), "%s -D LOCAL_MEM_TYPE=%u -D VENDOR_ID=%u -D CUDA_ARCH=%u -D AMD_ROCM=%u -D VECT_SIZE=%u -D DEVICE_TYPE=%u -D DGST_R0=%u -D DGST_R1=%u -D DGST_R2=%u -D DGST_R3=%u -D DGST_ELEM=%u -D KERN_TYPE=%u -D _unroll", build_opts_base, device_param->device_local_mem_type, device_param->platform_vendor_id, (device_param->sm_major * 100) + device_param->sm_minor, device_param->is_rocm, device_param->vector_width, (u32) device_param->device_type, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, hashconfig->dgst_size / 4, hashconfig->kern_type);
#else #else
snprintf (build_opts, sizeof (build_opts) - 1, "%s -D LOCAL_MEM_TYPE=%u -D VENDOR_ID=%u -D CUDA_ARCH=%u -D AMD_ROCM=%u -D VECT_SIZE=%u -D DEVICE_TYPE=%u -D DGST_R0=%u -D DGST_R1=%u -D DGST_R2=%u -D DGST_R3=%u -D DGST_ELEM=%u -D KERN_TYPE=%u -D _unroll -w", build_opts_base, device_param->device_local_mem_type, device_param->platform_vendor_id, (device_param->sm_major * 100) + device_param->sm_minor, device_param->is_rocm, device_param->vector_width, (u32) device_param->device_type, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, hashconfig->dgst_size / 4, hashconfig->kern_type); snprintf (build_opts, sizeof (build_opts), "%s -D LOCAL_MEM_TYPE=%u -D VENDOR_ID=%u -D CUDA_ARCH=%u -D AMD_ROCM=%u -D VECT_SIZE=%u -D DEVICE_TYPE=%u -D DGST_R0=%u -D DGST_R1=%u -D DGST_R2=%u -D DGST_R3=%u -D DGST_ELEM=%u -D KERN_TYPE=%u -D _unroll -w", build_opts_base, device_param->device_local_mem_type, device_param->platform_vendor_id, (device_param->sm_major * 100) + device_param->sm_minor, device_param->is_rocm, device_param->vector_width, (u32) device_param->device_type, hashconfig->dgst_pos0, hashconfig->dgst_pos1, hashconfig->dgst_pos2, hashconfig->dgst_pos3, hashconfig->dgst_size / 4, hashconfig->kern_type);
#endif #endif
/* /*
@ -4926,11 +4926,11 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
char *device_name_chksum_amp_mp = (char *) hcmalloc (HCBUFSIZ_TINY); char *device_name_chksum_amp_mp = (char *) hcmalloc (HCBUFSIZ_TINY);
#if defined (__x86_64__) #if defined (__x86_64__)
const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%d-%u-%u-%s-%s-%s-%d-%u-%u", 64, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime, user_options->opencl_vector_width, user_options->hash_mode); const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY, "%d-%u-%u-%s-%s-%s-%d-%u-%u", 64, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime, user_options->opencl_vector_width, user_options->hash_mode);
const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY - 1, "%d-%u-%s-%s-%s-%d", 64, device_param->platform_vendor_id, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime); const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY, "%d-%u-%s-%s-%s-%d", 64, device_param->platform_vendor_id, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime);
#else #else
const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%d-%u-%u-%s-%s-%s-%d-%u-%u", 32, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime, user_options->opencl_vector_width, user_options->hash_mode); const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY, "%d-%u-%u-%s-%s-%s-%d-%u-%u", 32, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime, user_options->opencl_vector_width, user_options->hash_mode);
const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY - 1, "%d-%u-%s-%s-%s-%d", 32, device_param->platform_vendor_id, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime); const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY, "%d-%u-%s-%s-%s-%d", 32, device_param->platform_vendor_id, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime);
#endif #endif
u32 device_name_digest[4] = { 0 }; u32 device_name_digest[4] = { 0 };
@ -4940,7 +4940,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
md5_64 ((u32 *) (device_name_chksum + i), device_name_digest); md5_64 ((u32 *) (device_name_chksum + i), device_name_digest);
} }
snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%08x", device_name_digest[0]); snprintf (device_name_chksum, HCBUFSIZ_TINY, "%08x", device_name_digest[0]);
u32 device_name_digest_amp_mp[4] = { 0 }; u32 device_name_digest_amp_mp[4] = { 0 };
@ -4949,7 +4949,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
md5_64 ((u32 *) (device_name_chksum_amp_mp + i), device_name_digest_amp_mp); md5_64 ((u32 *) (device_name_chksum_amp_mp + i), device_name_digest_amp_mp);
} }
snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY - 1, "%08x", device_name_digest_amp_mp[0]); snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY, "%08x", device_name_digest_amp_mp[0]);
/** /**
* main kernel * main kernel
@ -5734,7 +5734,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
{ {
// kernel1 // kernel1
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_s%02d", hashconfig->kern_type, 4); snprintf (kernel_name, sizeof (kernel_name), "m%05u_s%02d", hashconfig->kern_type, 4);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1);
@ -5754,7 +5754,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
// kernel2 // kernel2
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_s%02d", hashconfig->kern_type, 8); snprintf (kernel_name, sizeof (kernel_name), "m%05u_s%02d", hashconfig->kern_type, 8);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2);
@ -5774,7 +5774,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
// kernel3 // kernel3
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_s%02d", hashconfig->kern_type, 16); snprintf (kernel_name, sizeof (kernel_name), "m%05u_s%02d", hashconfig->kern_type, 16);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3);
@ -5794,7 +5794,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
} }
else else
{ {
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_sxx", hashconfig->kern_type); snprintf (kernel_name, sizeof (kernel_name), "m%05u_sxx", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel4); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel4);
@ -5819,7 +5819,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
{ {
// kernel1 // kernel1
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_m%02d", hashconfig->kern_type, 4); snprintf (kernel_name, sizeof (kernel_name), "m%05u_m%02d", hashconfig->kern_type, 4);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1);
@ -5839,7 +5839,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
// kernel2 // kernel2
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_m%02d", hashconfig->kern_type, 8); snprintf (kernel_name, sizeof (kernel_name), "m%05u_m%02d", hashconfig->kern_type, 8);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2);
@ -5859,7 +5859,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
// kernel3 // kernel3
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_m%02d", hashconfig->kern_type, 16); snprintf (kernel_name, sizeof (kernel_name), "m%05u_m%02d", hashconfig->kern_type, 16);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3);
@ -5879,7 +5879,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
} }
else else
{ {
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_mxx", hashconfig->kern_type); snprintf (kernel_name, sizeof (kernel_name), "m%05u_mxx", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel4); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel4);
@ -5908,7 +5908,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
{ {
if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE)
{ {
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_tm", hashconfig->kern_type); snprintf (kernel_name, sizeof (kernel_name), "m%05u_tm", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_tm); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_tm);
@ -5933,7 +5933,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
{ {
// kernel1 // kernel1
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_init", hashconfig->kern_type); snprintf (kernel_name, sizeof (kernel_name), "m%05u_init", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1);
@ -5953,7 +5953,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
// kernel2 // kernel2
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_loop", hashconfig->kern_type); snprintf (kernel_name, sizeof (kernel_name), "m%05u_loop", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2);
@ -5973,7 +5973,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
// kernel3 // kernel3
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_comp", hashconfig->kern_type); snprintf (kernel_name, sizeof (kernel_name), "m%05u_comp", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3);
@ -5995,7 +5995,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->opts_type & OPTS_TYPE_HOOK12) if (hashconfig->opts_type & OPTS_TYPE_HOOK12)
{ {
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_hook12", hashconfig->kern_type); snprintf (kernel_name, sizeof (kernel_name), "m%05u_hook12", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel12); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel12);
@ -6018,7 +6018,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->opts_type & OPTS_TYPE_HOOK23) if (hashconfig->opts_type & OPTS_TYPE_HOOK23)
{ {
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_hook23", hashconfig->kern_type); snprintf (kernel_name, sizeof (kernel_name), "m%05u_hook23", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel23); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel23);
@ -6041,7 +6041,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->opts_type & OPTS_TYPE_INIT2) if (hashconfig->opts_type & OPTS_TYPE_INIT2)
{ {
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_init2", hashconfig->kern_type); snprintf (kernel_name, sizeof (kernel_name), "m%05u_init2", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_init2); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_init2);
@ -6064,7 +6064,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->opts_type & OPTS_TYPE_LOOP2) if (hashconfig->opts_type & OPTS_TYPE_LOOP2)
{ {
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_loop2", hashconfig->kern_type); snprintf (kernel_name, sizeof (kernel_name), "m%05u_loop2", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_loop2); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_loop2);
@ -6087,7 +6087,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->opts_type & OPTS_TYPE_AUX1) if (hashconfig->opts_type & OPTS_TYPE_AUX1)
{ {
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_aux1", hashconfig->kern_type); snprintf (kernel_name, sizeof (kernel_name), "m%05u_aux1", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux1); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux1);
@ -6110,7 +6110,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->opts_type & OPTS_TYPE_AUX2) if (hashconfig->opts_type & OPTS_TYPE_AUX2)
{ {
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_aux2", hashconfig->kern_type); snprintf (kernel_name, sizeof (kernel_name), "m%05u_aux2", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux2); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux2);
@ -6133,7 +6133,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->opts_type & OPTS_TYPE_AUX3) if (hashconfig->opts_type & OPTS_TYPE_AUX3)
{ {
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_aux3", hashconfig->kern_type); snprintf (kernel_name, sizeof (kernel_name), "m%05u_aux3", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux3); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux3);
@ -6156,7 +6156,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->opts_type & OPTS_TYPE_AUX4) if (hashconfig->opts_type & OPTS_TYPE_AUX4)
{ {
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_aux4", hashconfig->kern_type); snprintf (kernel_name, sizeof (kernel_name), "m%05u_aux4", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux4); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux4);

View File

@ -55,10 +55,10 @@ static char *status_get_rules_file (const hashcat_ctx_t *hashcat_ctx)
for (i = 0; i < user_options->rp_files_cnt - 1; i++) for (i = 0; i < user_options->rp_files_cnt - 1; i++)
{ {
tmp_len += snprintf (tmp_buf + tmp_len, HCBUFSIZ_TINY - tmp_len - 1, "%s, ", user_options->rp_files[i]); tmp_len += snprintf (tmp_buf + tmp_len, HCBUFSIZ_TINY - tmp_len, "%s, ", user_options->rp_files[i]);
} }
tmp_len += snprintf (tmp_buf + tmp_len, HCBUFSIZ_TINY - tmp_len - 1, "%s", user_options->rp_files[i]); tmp_len += snprintf (tmp_buf + tmp_len, HCBUFSIZ_TINY - tmp_len, "%s", user_options->rp_files[i]);
tmp_buf[tmp_len] = 0; tmp_buf[tmp_len] = 0;
@ -78,34 +78,34 @@ void format_timer_display (struct tm *tm, char *buf, size_t len)
const char *time_entity1 = ((tm->tm_year - 70) == 1) ? time_entities_s[0] : time_entities_m[0]; const char *time_entity1 = ((tm->tm_year - 70) == 1) ? time_entities_s[0] : time_entities_m[0];
const char *time_entity2 = ( tm->tm_yday == 1) ? time_entities_s[1] : time_entities_m[1]; const char *time_entity2 = ( tm->tm_yday == 1) ? time_entities_s[1] : time_entities_m[1];
snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_year - 70, time_entity1, tm->tm_yday, time_entity2); snprintf (buf, len, "%d %s, %d %s", tm->tm_year - 70, time_entity1, tm->tm_yday, time_entity2);
} }
else if (tm->tm_yday) else if (tm->tm_yday)
{ {
const char *time_entity1 = (tm->tm_yday == 1) ? time_entities_s[1] : time_entities_m[1]; const char *time_entity1 = (tm->tm_yday == 1) ? time_entities_s[1] : time_entities_m[1];
const char *time_entity2 = (tm->tm_hour == 1) ? time_entities_s[2] : time_entities_m[2]; const char *time_entity2 = (tm->tm_hour == 1) ? time_entities_s[2] : time_entities_m[2];
snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_yday, time_entity1, tm->tm_hour, time_entity2); snprintf (buf, len, "%d %s, %d %s", tm->tm_yday, time_entity1, tm->tm_hour, time_entity2);
} }
else if (tm->tm_hour) else if (tm->tm_hour)
{ {
const char *time_entity1 = (tm->tm_hour == 1) ? time_entities_s[2] : time_entities_m[2]; const char *time_entity1 = (tm->tm_hour == 1) ? time_entities_s[2] : time_entities_m[2];
const char *time_entity2 = (tm->tm_min == 1) ? time_entities_s[3] : time_entities_m[3]; const char *time_entity2 = (tm->tm_min == 1) ? time_entities_s[3] : time_entities_m[3];
snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_hour, time_entity1, tm->tm_min, time_entity2); snprintf (buf, len, "%d %s, %d %s", tm->tm_hour, time_entity1, tm->tm_min, time_entity2);
} }
else if (tm->tm_min) else if (tm->tm_min)
{ {
const char *time_entity1 = (tm->tm_min == 1) ? time_entities_s[3] : time_entities_m[3]; const char *time_entity1 = (tm->tm_min == 1) ? time_entities_s[3] : time_entities_m[3];
const char *time_entity2 = (tm->tm_sec == 1) ? time_entities_s[4] : time_entities_m[4]; const char *time_entity2 = (tm->tm_sec == 1) ? time_entities_s[4] : time_entities_m[4];
snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_min, time_entity1, tm->tm_sec, time_entity2); snprintf (buf, len, "%d %s, %d %s", tm->tm_min, time_entity1, tm->tm_sec, time_entity2);
} }
else else
{ {
const char *time_entity1 = (tm->tm_sec == 1) ? time_entities_s[4] : time_entities_m[4]; const char *time_entity1 = (tm->tm_sec == 1) ? time_entities_s[4] : time_entities_m[4];
snprintf (buf, len - 1, "%d %s", tm->tm_sec, time_entity1); snprintf (buf, len, "%d %s", tm->tm_sec, time_entity1);
} }
} }
@ -133,11 +133,11 @@ void format_speed_display (double val, char *buf, size_t len)
if (level == 0) if (level == 0)
{ {
snprintf (buf, len - 1, "%.0f ", val); snprintf (buf, len, "%.0f ", val);
} }
else else
{ {
snprintf (buf, len - 1, "%.1f %c", val, UNITS[level]); snprintf (buf, len, "%.1f %c", val, UNITS[level]);
} }
} }
@ -165,11 +165,11 @@ void format_speed_display_1k (double val, char *buf, size_t len)
if (level == 0) if (level == 0)
{ {
snprintf (buf, len - 1, "%.0f ", val); snprintf (buf, len, "%.0f ", val);
} }
else else
{ {
snprintf (buf, len - 1, "%.1f %c", val, UNITS[level]); snprintf (buf, len, "%.1f %c", val, UNITS[level]);
} }
} }
@ -873,11 +873,11 @@ char *status_get_guess_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const i
if (user_options_extra->attack_kern == ATTACK_KERN_BF) if (user_options_extra->attack_kern == ATTACK_KERN_BF)
{ {
snprintf (display, HCBUFSIZ_TINY - 1, "[Generating]"); snprintf (display, HCBUFSIZ_TINY, "[Generating]");
} }
else else
{ {
snprintf (display, HCBUFSIZ_TINY - 1, "[Copying]"); snprintf (display, HCBUFSIZ_TINY, "[Copying]");
} }
if (device_param->skipped == true) return display; if (device_param->skipped == true) return display;
@ -918,14 +918,14 @@ char *status_get_guess_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const i
plain_ptr1[plain_len1 * 2] = 0; plain_ptr1[plain_len1 * 2] = 0;
plain_ptr2[plain_len2 * 2] = 0; plain_ptr2[plain_len2 * 2] = 0;
snprintf (display, HCBUFSIZ_TINY - 1, "$HEX[%s] -> $HEX[%s]", plain_ptr1, plain_ptr2); snprintf (display, HCBUFSIZ_TINY, "$HEX[%s] -> $HEX[%s]", plain_ptr1, plain_ptr2);
} }
else else
{ {
plain_ptr1[plain_len1] = 0; plain_ptr1[plain_len1] = 0;
plain_ptr2[plain_len2] = 0; plain_ptr2[plain_len2] = 0;
snprintf (display, HCBUFSIZ_TINY - 1, "%s -> %s", plain_ptr1, plain_ptr2); snprintf (display, HCBUFSIZ_TINY, "%s -> %s", plain_ptr1, plain_ptr2);
} }
return display; return display;
@ -1160,13 +1160,13 @@ char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx)
format_timer_display (tmp_left, display_left, HCBUFSIZ_TINY); format_timer_display (tmp_left, display_left, HCBUFSIZ_TINY);
snprintf (display, HCBUFSIZ_TINY - 1, "%s; Runtime limited: %s", tmp_display, display_left); snprintf (display, HCBUFSIZ_TINY, "%s; Runtime limited: %s", tmp_display, display_left);
free (display_left); free (display_left);
} }
else else
{ {
snprintf (display, HCBUFSIZ_TINY - 1, "%s; Runtime limit exceeded", tmp_display); snprintf (display, HCBUFSIZ_TINY, "%s; Runtime limit exceeded", tmp_display);
} }
free (tmp_display); free (tmp_display);
@ -1895,7 +1895,7 @@ char *status_get_brain_link_recv_bytes_sec_dev (const hashcat_ctx_t *hashcat_ctx
char *display = (char *) hcmalloc (HCBUFSIZ_TINY); char *display = (char *) hcmalloc (HCBUFSIZ_TINY);
snprintf (display, HCBUFSIZ_TINY - 1, "%.2f M", (double) (brain_link_recv_bytes * 8) / 1024 / 1024); snprintf (display, HCBUFSIZ_TINY, "%.2f M", (double) (brain_link_recv_bytes * 8) / 1024 / 1024);
return display; return display;
} }
@ -1922,7 +1922,7 @@ char *status_get_brain_link_send_bytes_sec_dev (const hashcat_ctx_t *hashcat_ctx
char *display = (char *) hcmalloc (HCBUFSIZ_TINY); char *display = (char *) hcmalloc (HCBUFSIZ_TINY);
snprintf (display, HCBUFSIZ_TINY - 1, "%.2f M", (double) (brain_link_send_bytes * 8) / 1024 / 1024); snprintf (display, HCBUFSIZ_TINY, "%.2f M", (double) (brain_link_send_bytes * 8) / 1024 / 1024);
return display; return display;
} }
@ -1936,7 +1936,7 @@ char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int device_i
char *output_buf = (char *) hcmalloc (HCBUFSIZ_TINY); char *output_buf = (char *) hcmalloc (HCBUFSIZ_TINY);
snprintf (output_buf, HCBUFSIZ_TINY - 1, "N/A"); snprintf (output_buf, HCBUFSIZ_TINY, "N/A");
if (device_param->skipped == true) return output_buf; if (device_param->skipped == true) return output_buf;
@ -1991,7 +1991,7 @@ char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int device_i
} }
else else
{ {
snprintf (output_buf, HCBUFSIZ_TINY - 1, "N/A"); snprintf (output_buf, HCBUFSIZ_TINY, "N/A");
} }
hc_thread_mutex_unlock (status_ctx->mux_hwmon); hc_thread_mutex_unlock (status_ctx->mux_hwmon);