Fix some missing sign conversions

pull/526/head
jsteube 8 years ago
parent 8bf2d0eb5d
commit 892eccfd14

@ -8,7 +8,7 @@
#include <ctype.h>
int is_valid_hex_char (const u8 c);
bool is_valid_hex_char (const u8 c);
u8 hex_convert (const u8 c);

@ -7,13 +7,13 @@
#include "types.h"
#include "convert.h"
int is_valid_hex_char (const u8 c)
bool is_valid_hex_char (const u8 c)
{
if ((c >= '0') && (c <= '9')) return 1;
if ((c >= 'A') && (c <= 'F')) return 1;
if ((c >= 'a') && (c <= 'f')) return 1;
if ((c >= '0') && (c <= '9')) return true;
if ((c >= 'A') && (c <= 'F')) return true;
if ((c >= 'a') && (c <= 'f')) return true;
return 0;
return false;
}
u8 hex_convert (const u8 c)

@ -384,7 +384,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
if (hashconfig->pw_max != PW_DICTMAX1)
{
if (plain_len > hashconfig->pw_max) plain_len = hashconfig->pw_max;
if (plain_len > (int) hashconfig->pw_max) plain_len = (int) hashconfig->pw_max;
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
@ -417,7 +417,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
if (hashconfig->pw_max != PW_DICTMAX1)
{
if (plain_len > hashconfig->pw_max) plain_len = hashconfig->pw_max;
if (plain_len > (int) hashconfig->pw_max) plain_len = (int) hashconfig->pw_max;
}
}
@ -435,7 +435,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
if (hashconfig->opts_type & OPTS_TYPE_PT_UNICODE)
{
for (uint i = 0, j = 0; i < plain_len; i += 2, j += 1)
for (int i = 0, j = 0; i < plain_len; i += 2, j += 1)
{
plain_ptr[j] = plain_ptr[i];
}

@ -97,7 +97,7 @@ void induct_ctx_scan (induct_ctx_t *induct_ctx)
induct_ctx->induction_dictionaries_cnt = count_dictionaries (induct_ctx->induction_dictionaries);
qsort (induct_ctx->induction_dictionaries, induct_ctx->induction_dictionaries_cnt, sizeof (char *), sort_by_mtime);
qsort (induct_ctx->induction_dictionaries, (size_t) induct_ctx->induction_dictionaries_cnt, sizeof (char *), sort_by_mtime);
}
void induct_ctx_cleanup (induct_ctx_t *induct_ctx)

@ -30,19 +30,19 @@ static int log_final (FILE *fp, const char *fmt, va_list ap)
char s[4096] = { 0 };
int max_len = (int) sizeof (s);
const size_t max_len = sizeof (s);
int len = vsnprintf (s, (size_t)max_len, fmt, ap);
const int len = vsnprintf (s, max_len, fmt, ap);
if (len > max_len) len = max_len;
//if (len > max_len) len = max_len;
fwrite (s, len, 1, fp);
fwrite (s, (size_t) len, 1, fp);
fflush (fp);
last_len = len;
return len;
return last_len;
}
int log_out_nn (FILE *fp, const char *fmt, ...)

@ -212,7 +212,7 @@ void *thread_monitor (void *p)
{
int temp_cur = temperature;
int temp_diff_new = gpu_temp_retain - temp_cur;
int temp_diff_new = (int) gpu_temp_retain - temp_cur;
temp_diff_sum[device_id] = temp_diff_sum[device_id] + temp_diff_new;

@ -45,7 +45,7 @@ void mp_css_to_uniq_tbl (uint css_cnt, cs_t *css, uint uniq_tbls[SP_PW_MAX][CHAR
}
}
static void mp_add_cs_buf (uint *in_buf, size_t in_len, cs_t *css, int css_cnt, const hashconfig_t *hashconfig)
static void mp_add_cs_buf (uint *in_buf, size_t in_len, cs_t *css, uint css_cnt, const hashconfig_t *hashconfig)
{
cs_t *cs = &css[css_cnt];
@ -80,7 +80,7 @@ static void mp_add_cs_buf (uint *in_buf, size_t in_len, cs_t *css, int css_cnt,
myfree (css_uniq);
}
static void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, int mp_usr_offset, int interpret, const hashconfig_t *hashconfig, const user_options_t *user_options)
static void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, uint mp_usr_offset, int interpret, const hashconfig_t *hashconfig, const user_options_t *user_options)
{
size_t in_pos;
@ -143,7 +143,7 @@ static void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr,
uint p1 = in_buf[in_pos] & 0xff;
if ((is_valid_hex_char (p0) == 0) || (is_valid_hex_char (p1) == 0))
if ((is_valid_hex_char ((u8) p0) == false) || (is_valid_hex_char ((u8) p1) == false))
{
log_error ("ERROR: Invalid hex character detected in mask %s", in_buf);
@ -152,8 +152,8 @@ static void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr,
uint chr = 0;
chr = hex_convert (p1) << 0;
chr |= hex_convert (p0) << 4;
chr = (uint) hex_convert ((u8) p1) << 0;
chr |= (uint) hex_convert ((u8) p0) << 4;
mp_add_cs_buf (&chr, 1, mp_usr, mp_usr_offset, hashconfig);
}
@ -198,7 +198,7 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u
char p1 = mask_buf[mask_pos];
uint chr = p1;
uint chr = (uint) p1;
switch (p1)
{
@ -251,7 +251,7 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u
// if they are not valid hex character, show an error:
if ((is_valid_hex_char (p0) == 0) || (is_valid_hex_char (p1) == 0))
if ((is_valid_hex_char ((u8) p0) == false) || (is_valid_hex_char ((u8) p1) == false))
{
log_error ("ERROR: Invalid hex character detected in mask %s", mask_buf);
@ -260,14 +260,14 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u
uint chr = 0;
chr |= hex_convert (p1) << 0;
chr |= hex_convert (p0) << 4;
chr |= (uint) hex_convert ((u8) p1) << 0;
chr |= (uint) hex_convert ((u8) p0) << 4;
mp_add_cs_buf (&chr, 1, css, css_pos, hashconfig);
}
else
{
uint chr = p0;
uint chr = (uint) p0;
mp_add_cs_buf (&chr, 1, css, css_pos, hashconfig);
}
@ -290,10 +290,10 @@ void mp_exec (u64 val, char *buf, cs_t *css, int css_cnt)
{
for (int i = 0; i < css_cnt; i++)
{
uint len = css[i].cs_len;
u32 len = css[i].cs_len;
u64 next = val / len;
uint pos = val % len;
buf[i] = (char) css[i].cs_buf[pos] & 0xff;
u32 pos = val % len;
buf[i] = (char) (css[i].cs_buf[pos] & 0xff);
val = next;
}
}
@ -369,7 +369,7 @@ void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, uint index, const hash
{
char mp_file[1024] = { 0 };
size_t len = fread (mp_file, 1, sizeof (mp_file) - 1, fp);
int len = (int) fread (mp_file, 1, sizeof (mp_file) - 1, fp);
fclose (fp);
@ -383,7 +383,7 @@ void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, uint index, const hash
}
else
{
mp_expand (mp_file, len, mp_sys, mp_usr, index, 0, hashconfig, user_options);
mp_expand (mp_file, (size_t) len, mp_sys, mp_usr, index, 0, hashconfig, user_options);
}
}
}
@ -436,7 +436,7 @@ static char *mp_get_truncated_mask (const char *mask_buf, const size_t mask_len,
// if they are not valid hex character, show an error:
if ((is_valid_hex_char (p0) == 0) || (is_valid_hex_char (p1) == 0))
if ((is_valid_hex_char ((u8) p0) == false) || (is_valid_hex_char ((u8) p1) == false))
{
log_error ("ERROR: Invalid hex character detected in mask: %s", mask_buf);

Loading…
Cancel
Save