From f500727bd88e33b3d4fa9222397ad91d47b1712a Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sun, 30 Oct 2016 16:11:20 +0100 Subject: [PATCH] Fix string format --- src/opencl.c | 6 +++--- src/outfile.c | 2 +- src/status.c | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/opencl.c b/src/opencl.c index 828d5a328..1262ec394 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -2572,9 +2572,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) 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); + snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%d-%u-%u-%s-%s-%s-%d", 64, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, comptime); #else - snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%u-%u-%u-%s-%s-%s-%u", 32, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, comptime); + snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%d-%u-%u-%s-%s-%s-%d", 32, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, comptime); #endif u32 device_name_digest[4] = { 0 }; @@ -3452,7 +3452,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) snprintf (build_opts_new, sizeof (build_opts_new) - 1, "%s -D VENDOR_ID=%u -D CUDA_ARCH=%d -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 -cl-std=CL1.1 -w", build_opts, device_param->device_vendor_id, (device_param->sm_major * 100) + device_param->sm_minor, 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 - strncpy (build_opts, build_opts_new, sizeof (build_opts)); + strncpy (build_opts, build_opts_new, sizeof (build_opts) - 1); #if defined (DEBUG) if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: build_opts '%s'", device_id + 1, build_opts); diff --git a/src/outfile.c b/src/outfile.c index d632f1607..1a9f499b4 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -482,7 +482,7 @@ int outfile_and_hashfile (hashcat_ctx_t *hashcat_ctx) fclose (tmp_hashfile_fp); } - if (tmp_outfile_fp && tmp_outfile_fp) + if (tmp_outfile_fp) { tmpstat_outfile.st_mode = 0; tmpstat_outfile.st_nlink = 0; diff --git a/src/status.c b/src/status.c index c04d7fc68..61ed65594 100644 --- a/src/status.c +++ b/src/status.c @@ -1381,7 +1381,7 @@ char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx) if ((cpt_ctx->cpt_start + 86400) < now) { - snprintf (cpt, HCBUFSIZ_TINY - 1, "CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + snprintf (cpt, HCBUFSIZ_TINY - 1, "CUR:%d,%d,%d AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_cur_day, @@ -1391,7 +1391,7 @@ char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 3600) < now) { - snprintf (cpt, HCBUFSIZ_TINY - 1, "CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + snprintf (cpt, HCBUFSIZ_TINY - 1, "CUR:%d,%d,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_avg_min, @@ -1400,7 +1400,7 @@ char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 60) < now) { - snprintf (cpt, HCBUFSIZ_TINY - 1, "CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + snprintf (cpt, HCBUFSIZ_TINY - 1, "CUR:%d,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_avg_min, cpt_avg_hour, @@ -1445,42 +1445,42 @@ char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int device_i if (num_temperature >= 0) { - snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Temp:%3uc ", num_temperature); + snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Temp:%3dc ", num_temperature); output_len = strlen (output_buf); } if (num_fanspeed >= 0) { - snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Fan:%3u%% ", num_fanspeed); + snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Fan:%3d%% ", num_fanspeed); output_len = strlen (output_buf); } if (num_utilization >= 0) { - snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Util:%3u%% ", num_utilization); + snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Util:%3d%% ", num_utilization); output_len = strlen (output_buf); } if (num_corespeed >= 0) { - snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Core:%4uMhz ", num_corespeed); + snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Core:%4dMhz ", num_corespeed); output_len = strlen (output_buf); } if (num_memoryspeed >= 0) { - snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Mem:%4uMhz ", num_memoryspeed); + snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Mem:%4dMhz ", num_memoryspeed); output_len = strlen (output_buf); } if (num_buslanes >= 0) { - snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Lanes:%u ", num_buslanes); + snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Lanes:%d ", num_buslanes); output_len = strlen (output_buf); }