Fix compiler warnings caused by -Wshadow

pull/563/head
jsteube 8 years ago
parent 6133809704
commit 7eef713ff7

@ -1 +1 @@
Subproject commit 8e196ba99632fc43998cf17cce87282c250d9177
Subproject commit 2d06e097f3dc61ce3ceeafeec203e9ee9e68f330

@ -98,7 +98,17 @@ BINARY_NATIVE := $(PROG_NAME)
## General compiler and linker flags
##
CFLAGS := -pipe -W -Wall -std=c99 -Iinclude/ -IOpenCL/ -Wundef -Wmissing-declarations -Wmissing-prototypes -Wdouble-promotion
CFLAGS := -pipe -std=c99 -Iinclude/ -IOpenCL/
CFLAGS += -W
CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -Wfloat-equal
CFLAGS += -Wundef
CFLAGS += -Wshadow
CFLAGS += -Wmissing-declarations
CFLAGS += -Wmissing-prototypes
CFLAGS += -ftrapv
LFLAGS :=
ifndef DEBUG

@ -167,7 +167,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
double exec_msec = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops);
for (int i = 0; i < VERIFIER_CNT; i++)
for (int verifier_idx = 0; verifier_idx < VERIFIER_CNT; verifier_idx++)
{
double exec_msec_v = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops);
@ -190,7 +190,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
double exec_msec_pre_final = try_run (hashcat_ctx, device_param, kernel_accel, kernel_loops);
for (int i = 0; i < VERIFIER_CNT; i++)
for (int verifier_idx = 0; verifier_idx < VERIFIER_CNT; verifier_idx++)
{
double exec_msec_pre_final_v = try_run (hashcat_ctx, device_param, kernel_accel, kernel_loops);
@ -220,14 +220,14 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
double exec_msec = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops_try);
for (int i = 0; i < VERIFIER_CNT; i++)
for (int verifier_idx = 0; verifier_idx < VERIFIER_CNT; verifier_idx++)
{
double exec_msec_v = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops_try);
exec_msec = MIN (exec_msec, exec_msec_v);
}
if (exec_msec < exec_msec_pre_final)
for (int verifier_idx = 0; verifier_idx < VERIFIER_CNT; verifier_idx++)
{
exec_msec_pre_final = exec_msec;

@ -13129,8 +13129,6 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos,
char *ptr = (char *) salt.salt_buf;
u32 len = salt.salt_len;
if (opti_type & OPTI_TYPE_PRECOMPUTE_PERMUT)
{
u32 tt;
@ -13148,21 +13146,23 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos,
}
}
u32 salt_len = salt.salt_len;
if (opts_type & OPTS_TYPE_ST_UNICODE)
{
for (u32 i = 0, j = 0; i < len; i += 1, j += 2)
for (u32 i = 0, j = 0; i < salt_len; i += 1, j += 2)
{
ptr[i] = ptr[j];
}
len = len / 2;
salt_len = salt_len / 2;
}
if (opts_type & OPTS_TYPE_ST_GENERATE_LE)
{
u32 max = salt.salt_len / 4;
if (len % 4) max++;
if (salt_len % 4) max++;
for (u32 i = 0; i < max; i++)
{
@ -13174,21 +13174,21 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos,
{
char tmp[64] = { 0 };
for (u32 i = 0, j = 0; i < len; i += 1, j += 2)
for (u32 i = 0, j = 0; i < salt_len; i += 1, j += 2)
{
sprintf (tmp + j, "%02x", (unsigned char) ptr[i]);
}
len = len * 2;
salt_len = salt_len * 2;
memcpy (ptr, tmp, len);
memcpy (ptr, tmp, salt_len);
}
u32 memset_size = ((48 - (int) len) > 0) ? (48 - len) : 0;
u32 memset_size = ((48 - (int) salt_len) > 0) ? (48 - salt_len) : 0;
memset (ptr + len, 0, memset_size);
memset (ptr + salt_len, 0, memset_size);
salt.salt_len = len;
salt.salt_len = salt_len;
}
//
@ -14433,9 +14433,8 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos,
digest_buf[7] = byte_swap_32 (digest_buf[7]);
digest_buf[8] = 0; // needed for base64_encode ()
char tmp_buf[64] = { 0 };
base64_encode (int_to_itoa64, (const u8 *) digest_buf, 32, (u8 *) tmp_buf);
tmp_buf[43] = 0; // cut it here
// output
@ -14454,9 +14453,8 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos,
digest_buf[7] = byte_swap_32 (digest_buf[7]);
digest_buf[8] = 0; // needed for base64_encode ()
char tmp_buf[64] = { 0 };
base64_encode (int_to_itoa64, (const u8 *) digest_buf, 32, (u8 *) tmp_buf);
tmp_buf[43] = 0; // cut it here
unsigned char *salt_buf_ptr = (unsigned char *) salt.salt_buf;
@ -14712,8 +14710,6 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos,
digest_buf[7] = byte_swap_32 (digest_buf[7]);
digest_buf[8] = 0; // needed for base64_encode ()
char tmp_buf[64] = { 0 };
base64_encode (int_to_base64, (const u8 *) digest_buf, 32, (u8 *) tmp_buf);
// output
@ -14746,9 +14742,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos,
// response
char tmp_buf[100] = { 0 };
u32 tmp_len = snprintf (tmp_buf, 100, "%s %08x%08x%08x%08x",
u32 tmp_len = snprintf (tmp_buf, sizeof (tmp_buf) - 1, "%s %08x%08x%08x%08x",
(char *) cram_md5->user,
digest_buf[0],
digest_buf[1],
@ -14763,8 +14757,6 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos,
}
else if (hash_mode == 10300)
{
char tmp_buf[100] = { 0 };
memcpy (tmp_buf + 0, digest_buf, 20);
memcpy (tmp_buf + 20, salt.salt_buf, salt.salt_len);
@ -15191,19 +15183,17 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos,
else if (hash_mode == 12200)
{
u32 *ptr_digest = digest_buf;
u32 *ptr_salt = salt.salt_buf;
snprintf (out_buf, len-1, "%s0$1$%08x%08x$%08x%08x",
SIGNATURE_ECRYPTFS,
ptr_salt[0],
ptr_salt[1],
salt.salt_buf[0],
salt.salt_buf[1],
ptr_digest[0],
ptr_digest[1]);
}
else if (hash_mode == 12300)
{
u32 *ptr_digest = digest_buf;
u32 *ptr_salt = salt.salt_buf;
snprintf (out_buf, len-1, "%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X",
ptr_digest[ 0], ptr_digest[ 1],
@ -15214,10 +15204,10 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos,
ptr_digest[10], ptr_digest[11],
ptr_digest[12], ptr_digest[13],
ptr_digest[14], ptr_digest[15],
ptr_salt[0],
ptr_salt[1],
ptr_salt[2],
ptr_salt[3]);
salt.salt_buf[0],
salt.salt_buf[1],
salt.salt_buf[2],
salt.salt_buf[3]);
}
else if (hash_mode == 12400)
{

@ -2038,7 +2038,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx)
cl_platform_id platform = platforms[platform_id];
int CL_rc = hc_clGetDeviceIDs (hashcat_ctx, platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, platform_devices, &platform_devices_cnt);
CL_rc = hc_clGetDeviceIDs (hashcat_ctx, platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, platform_devices, &platform_devices_cnt);
if (CL_rc == -1) continue;
@ -2048,7 +2048,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx)
cl_device_type device_type;
int CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device, CL_DEVICE_TYPE, sizeof (device_type), &device_type, NULL);
CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device, CL_DEVICE_TYPE, sizeof (device_type), &device_type, NULL);
if (CL_rc == -1) return -1;

@ -214,9 +214,9 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
// compare hex string(s) vs binary MAC address(es)
for (u32 i = 0, j = 0; i < 6; i++, j += 2)
for (u32 mac_idx = 0, orig_mac_idx = 0; mac_idx < 6; mac_idx++, orig_mac_idx += 2)
{
if (wpa->orig_mac1[i] != hex_to_u8 ((const u8 *) &mac1_pos[j]))
if (wpa->orig_mac1[mac_idx] != hex_to_u8 ((const u8 *) &mac1_pos[orig_mac_idx]))
{
cracked = 0;
@ -227,9 +227,9 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
// early skip ;)
if (!cracked) continue;
for (u32 i = 0, j = 0; i < 6; i++, j += 2)
for (u32 mac_idx = 0, orig_mac_idx = 0; mac_idx < 6; mac_idx++, orig_mac_idx += 2)
{
if (wpa->orig_mac2[i] != hex_to_u8 ((const u8 *) &mac2_pos[j]))
if (wpa->orig_mac2[mac_idx] != hex_to_u8 ((const u8 *) &mac2_pos[orig_mac_idx]))
{
cracked = 0;

@ -433,9 +433,9 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
// compare hex string(s) vs binary MAC address(es)
for (u32 i = 0, j = 0; i < 6; i++, j += 2)
for (u32 mac_idx = 0, orig_mac_idx = 0; mac_idx < 6; mac_idx += 1, orig_mac_idx += 2)
{
if (wpa->orig_mac1[i] != hex_to_u8 ((const u8 *) &mac1_pos[j]))
if (wpa->orig_mac1[mac_idx] != hex_to_u8 ((const u8 *) &mac1_pos[orig_mac_idx]))
{
found = NULL;
@ -446,9 +446,9 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
// early skip ;)
if (!found) continue;
for (u32 i = 0, j = 0; i < 6; i++, j += 2)
for (u32 mac_idx = 0, orig_mac_idx = 0; mac_idx < 6; mac_idx += 1, orig_mac_idx += 2)
{
if (wpa->orig_mac2[i] != hex_to_u8 ((const u8 *) &mac2_pos[j]))
if (wpa->orig_mac2[mac_idx] != hex_to_u8 ((const u8 *) &mac2_pos[orig_mac_idx]))
{
found = NULL;

@ -853,7 +853,7 @@ char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx)
{
const int runtime_left = get_runtime_left (hashcat_ctx);
char *tmp = strdup (display);
char *tmp_display = strdup (display);
if (runtime_left > 0)
{
@ -875,16 +875,16 @@ char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx)
format_timer_display (tmp_left, display_left, HCBUFSIZ_TINY);
snprintf (display, HCBUFSIZ_TINY - 1, "%s; Runtime limited: %s", tmp, display_left);
snprintf (display, HCBUFSIZ_TINY - 1, "%s; Runtime limited: %s", tmp_display, display_left);
free (display_left);
}
else
{
snprintf (display, HCBUFSIZ_TINY - 1, "%s; Runtime limit exceeded", tmp);
snprintf (display, HCBUFSIZ_TINY - 1, "%s; Runtime limit exceeded", tmp_display);
}
free (tmp);
free (tmp_display);
}
return display;

Loading…
Cancel
Save