mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-26 09:58:16 +00:00
Use __attribute__ ((format (printf, 2, 3))) to help compiler to identify format strings
This commit is contained in:
parent
a599b06a53
commit
3442892fda
@ -14,13 +14,13 @@ void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, cons
|
||||
#define EVENT(id) event_call ((id), hashcat_ctx, NULL, 0)
|
||||
#define EVENT_DATA(id,buf,len) event_call ((id), hashcat_ctx, (buf), (len))
|
||||
|
||||
size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
|
||||
size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
|
||||
size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
|
||||
size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
|
||||
size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
|
||||
size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
|
||||
size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
|
||||
size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
|
||||
int event_ctx_init (hashcat_ctx_t *hashcat_ctx);
|
||||
void event_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
void logfile_generate_topid (hashcat_ctx_t *hashcat_ctx);
|
||||
void logfile_generate_subid (hashcat_ctx_t *hashcat_ctx);
|
||||
void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
|
||||
void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
int logfile_init (hashcat_ctx_t *hashcat_ctx);
|
||||
void logfile_destroy (hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
|
@ -116,6 +116,7 @@ CFLAGS += -Winit-self
|
||||
CFLAGS += -Werror-implicit-function-declaration
|
||||
CFLAGS += -Wformat
|
||||
CFLAGS += -ftrapv
|
||||
CFLAGS += -Wno-format-zero-length
|
||||
|
||||
# the following compiler options produce warnings that should be fixed at some time
|
||||
|
||||
|
@ -68,7 +68,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (S_ISDIR (tmp_stat.st_mode))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s must be a regular file", dictfile1, strerror (errno));
|
||||
event_log_error (hashcat_ctx, "%s must be a regular file", dictfile1);
|
||||
|
||||
fclose (fp1);
|
||||
|
||||
@ -96,7 +96,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (S_ISDIR (tmp_stat.st_mode))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s must be a regular file", dictfile2, strerror (errno));
|
||||
event_log_error (hashcat_ctx, "%s must be a regular file", dictfile2);
|
||||
|
||||
fclose (fp1);
|
||||
fclose (fp2);
|
||||
|
@ -374,7 +374,7 @@ int base32_encode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf
|
||||
out_ptr += 8;
|
||||
}
|
||||
|
||||
int out_len = (int) (((0.5 + (double) in_len) * 8) / 5); // ceil (in_len * 8 / 5)
|
||||
int out_len = (int) (((0.5f + (double) in_len) * 8) / 5); // ceil (in_len * 8 / 5)
|
||||
|
||||
while (out_len % 8)
|
||||
{
|
||||
@ -441,7 +441,7 @@ int base64_encode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf
|
||||
out_ptr += 4;
|
||||
}
|
||||
|
||||
int out_len = (int) (((0.5 + (double) in_len) * 8) / 6); // ceil (in_len * 8 / 6)
|
||||
int out_len = (int) (((0.5f + (double) in_len) * 8) / 6); // ceil (in_len * 8 / 6)
|
||||
|
||||
while (out_len % 4)
|
||||
{
|
||||
|
@ -263,8 +263,8 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
status_ctx->runtime_stop = runtime_stop;
|
||||
|
||||
logfile_sub_uint (runtime_start);
|
||||
logfile_sub_uint (runtime_stop);
|
||||
logfile_sub_uint ((u32) runtime_start);
|
||||
logfile_sub_uint ((u32) runtime_stop);
|
||||
|
||||
time (&status_ctx->prepare_start);
|
||||
|
||||
@ -1088,8 +1088,8 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
const time_t proc_stop = time (NULL);
|
||||
|
||||
logfile_top_uint (proc_start);
|
||||
logfile_top_uint (proc_stop);
|
||||
logfile_top_uint ((u32) proc_start);
|
||||
logfile_top_uint ((u32) proc_stop);
|
||||
|
||||
logfile_top_msg ("STOP");
|
||||
|
||||
|
@ -3032,11 +3032,11 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int engine_clock_max = (int) (0.6666 * caps.sEngineClockRange.iMax);
|
||||
int memory_clock_max = (int) (0.6250 * caps.sMemoryClockRange.iMax);
|
||||
int engine_clock_max = (int) (0.6666f * caps.sEngineClockRange.iMax);
|
||||
int memory_clock_max = (int) (0.6250f * caps.sMemoryClockRange.iMax);
|
||||
|
||||
int warning_trigger_engine = (int) (0.25 * engine_clock_max);
|
||||
int warning_trigger_memory = (int) (0.25 * memory_clock_max);
|
||||
int warning_trigger_engine = (int) (0.25f * engine_clock_max);
|
||||
int warning_trigger_memory = (int) (0.25f * memory_clock_max);
|
||||
|
||||
int engine_clock_profile_max = hwmon_ctx->od_clock_mem_status[device_id].state.aLevels[1].iEngineClock;
|
||||
int memory_clock_profile_max = hwmon_ctx->od_clock_mem_status[device_id].state.aLevels[1].iMemoryClock;
|
||||
|
@ -719,11 +719,11 @@ static void main_hashlist_parse_hash (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M
|
||||
|
||||
if (hashes_cnt < hashes_avail)
|
||||
{
|
||||
event_log_info_nn (hashcat_ctx, "Parsing Hashes: %u/%u (%0.2f%%)...", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
|
||||
event_log_info_nn (hashcat_ctx, "Parsing Hashes: %u/%u (%0.2f%%)...", hashes_cnt, hashes_avail, (hashes_cnt / hashes_avail) * 100.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, 100);
|
||||
event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, 100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -509,8 +509,8 @@ void opencl_info (hashcat_ctx_t *hashcat_ctx)
|
||||
event_log_info (hashcat_ctx, " Processor(s) : %u", device_processors);
|
||||
event_log_info (hashcat_ctx, " Clock : %u", device_maxclock_frequency);
|
||||
event_log_info (hashcat_ctx, " Memory : %" PRIu64 "/%" PRIu64 " MB allocatable", device_maxmem_alloc / 1024 / 1024, device_global_mem / 1024 / 1024);
|
||||
event_log_info (hashcat_ctx, " OpenCL Version : %u", device_opencl_version);
|
||||
event_log_info (hashcat_ctx, " Driver Version : %u", driver_version);
|
||||
event_log_info (hashcat_ctx, " OpenCL Version : %s", device_opencl_version);
|
||||
event_log_info (hashcat_ctx, " Driver Version : %s", driver_version);
|
||||
event_log_info (hashcat_ctx, "");
|
||||
}
|
||||
}
|
||||
@ -546,7 +546,7 @@ void opencl_info_compact (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
line[len] = 0;
|
||||
|
||||
event_log_info (hashcat_ctx, line);
|
||||
event_log_info (hashcat_ctx, "%s", line);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -566,12 +566,12 @@ void opencl_info_compact (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (device_param->skipped == false)
|
||||
{
|
||||
event_log_info (hashcat_ctx, "* Device #%u: %s, %lu/%lu MB allocatable, %uMCU",
|
||||
event_log_info (hashcat_ctx, "* Device #%u: %s, %" PRIu64 "/%" PRIu64 " MB allocatable, %uMCU",
|
||||
devices_idx + 1,
|
||||
device_name,
|
||||
(unsigned int) (device_maxmem_alloc / 1024 / 1024),
|
||||
(unsigned int) (device_global_mem / 1024 / 1024),
|
||||
(unsigned int) device_processors);
|
||||
device_maxmem_alloc / 1024 / 1024,
|
||||
device_global_mem / 1024 / 1024,
|
||||
device_processors);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user