From c13ef5aacda21b7db4482231b26e02d8e4ae763e Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Wed, 16 Nov 2016 20:30:14 -0800 Subject: [PATCH 1/3] Fix formats found by cppcheck --- src/interface.c | 10 +++++----- src/opencl.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/interface.c b/src/interface.c index f92de66f2..56045321e 100644 --- a/src/interface.c +++ b/src/interface.c @@ -14439,7 +14439,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, base64_encode (int_to_base64, (const u8 *) digest_buf, 32, (u8 *) tmp_buf); - snprintf (out_buf, len-1, "%s:%i:%i:%i:%s:%s", + snprintf (out_buf, len-1, "%s:%u:%u:%u:%s:%s", SIGNATURE_SCRYPT, N, r, @@ -15477,7 +15477,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, if (version == 1) final_random_seed_len = 4; - snprintf (out_buf, len-1, "%s*%d*%d*%d", + snprintf (out_buf, len-1, "%s*%u*%u*%u", SIGNATURE_KEEPASS, version, rounds, @@ -15528,9 +15528,9 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, char ptr_contents_len[10] = { 0 }; - sprintf ((char*) ptr_contents_len, "%d", contents_len); + sprintf ((char*) ptr_contents_len, "%u", contents_len); - sprintf (ptr_data, "%d", contents_len); + sprintf (ptr_data, "%u", contents_len); ptr_data += strlen(ptr_contents_len); @@ -15566,7 +15566,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, *ptr_data = '*'; ptr_data++; - sprintf (ptr_data, "%d", keyfile_len); + sprintf (ptr_data, "%u", keyfile_len); ptr_data += 2; diff --git a/src/opencl.c b/src/opencl.c index 414df731d..a0f0374a7 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -160,12 +160,12 @@ static void generate_cached_kernel_mp_filename (const u32 opti_type, const u32 o static void generate_source_kernel_amp_filename (const u32 attack_kern, char *shared_dir, char *source_file) { - snprintf (source_file, 255, "%s/OpenCL/amp_a%d.cl", shared_dir, attack_kern); + snprintf (source_file, 255, "%s/OpenCL/amp_a%u.cl", shared_dir, attack_kern); } static void generate_cached_kernel_amp_filename (const u32 attack_kern, char *profile_dir, const char *device_name_chksum, char *cached_file) { - snprintf (cached_file, 255, "%s/kernels/amp_a%d.%s.kernel", profile_dir, attack_kern, device_name_chksum); + snprintf (cached_file, 255, "%s/kernels/amp_a%u.%s.kernel", profile_dir, attack_kern, device_name_chksum); } static int setup_opencl_platforms_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_platforms, u32 *out) From 4e82eb9281f2405fbb306f013734ae2eaa38a156 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Wed, 16 Nov 2016 20:43:17 -0800 Subject: [PATCH 2/3] Replace atoi with atoll. Eliminates sign conversion warnings --- src/interface.c | 136 ++++++++++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/interface.c b/src/interface.c index 56045321e..ddf38221a 100644 --- a/src/interface.c +++ b/src/interface.c @@ -2126,7 +2126,7 @@ int bcrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU u8 *iter_pos = input_buf + 4; - salt->salt_iter = 1u << atoi ((const char *) iter_pos); + salt->salt_iter = 1u << atoll ((const char *) iter_pos); u8 *salt_pos = (u8 *) strchr ((const char *) iter_pos, '$'); @@ -2563,7 +2563,7 @@ int dcc2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE salt_t *salt = hash_buf->salt; - u32 iter = atoi ((const char *) iter_pos); + u32 iter = atoll ((const char *) iter_pos); if (iter < 1) { @@ -2883,7 +2883,7 @@ int md5crypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U salt_pos[0] = 0x0; - salt->salt_iter = atoi ((const char *) (salt_pos - iterations_len)); + salt->salt_iter = atoll ((const char *) (salt_pos - iterations_len)); salt_pos += 1; @@ -2942,7 +2942,7 @@ int md5apr1_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN salt_pos[0] = 0x0; - salt->salt_iter = atoi ((const char *) (salt_pos - iterations_len)); + salt->salt_iter = atoll ((const char *) (salt_pos - iterations_len)); salt_pos += 1; @@ -4731,7 +4731,7 @@ int sha512crypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYB salt_pos[0] = 0x0; - salt->salt_iter = atoi ((const char *) (salt_pos - iterations_len)); + salt->salt_iter = atoll ((const char *) (salt_pos - iterations_len)); salt_pos += 1; @@ -5340,9 +5340,9 @@ int sha1aix_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN char salt_iter[3] = { iter_pos[0], iter_pos[1], 0 }; - salt->salt_sign[0] = atoi ((const char *) salt_iter); + salt->salt_sign[0] = atoll ((const char *) salt_iter); - salt->salt_iter = (1u << atoi ((const char *) salt_iter)) - 1; + salt->salt_iter = (1u << atoll ((const char *) salt_iter)) - 1; hash_pos++; @@ -5389,9 +5389,9 @@ int sha256aix_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_ char salt_iter[3] = { iter_pos[0], iter_pos[1], 0 }; - salt->salt_sign[0] = atoi ((const char *) salt_iter); + salt->salt_sign[0] = atoll ((const char *) salt_iter); - salt->salt_iter = (1u << atoi ((const char *) salt_iter)) - 1; + salt->salt_iter = (1u << atoll ((const char *) salt_iter)) - 1; hash_pos++; @@ -5441,9 +5441,9 @@ int sha512aix_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_ char salt_iter[3] = { iter_pos[0], iter_pos[1], 0 }; - salt->salt_sign[0] = atoi ((const char *) salt_iter); + salt->salt_sign[0] = atoll ((const char *) salt_iter); - salt->salt_iter = (1u << atoi ((const char *) salt_iter)) - 1; + salt->salt_iter = (1u << atoll ((const char *) salt_iter)) - 1; hash_pos++; @@ -5505,7 +5505,7 @@ int agilekey_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U * pbkdf2 iterations */ - salt->salt_iter = atoi ((const char *) iterations_pos) - 1; + salt->salt_iter = atoll ((const char *) iterations_pos) - 1; /** * handle salt encoding @@ -5615,7 +5615,7 @@ int lastpass_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U salt->salt_len = salt_len; - salt->salt_iter = atoi ((const char *) iterations_pos) - 1; + salt->salt_iter = atoll ((const char *) iterations_pos) - 1; digest[0] = hex_to_u32 ((const u8 *) &hashbuf_pos[ 0]); digest[1] = hex_to_u32 ((const u8 *) &hashbuf_pos[ 8]); @@ -5675,7 +5675,7 @@ int sha256crypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYB salt_pos[0] = 0x0; - salt->salt_iter = atoi ((const char *) (salt_pos - iterations_len)); + salt->salt_iter = atoll ((const char *) (salt_pos - iterations_len)); salt_pos += 1; @@ -5774,7 +5774,7 @@ int sha512osx_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_ salt->salt_buf[0] = pbkdf2_sha512->salt_buf[0]; - salt->salt_iter = atoi ((const char *) iter_pos) - 1; + salt->salt_iter = atoll ((const char *) iter_pos) - 1; return (PARSER_OK); } @@ -5893,7 +5893,7 @@ int sha512grub_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE salt->salt_len = salt_len; - salt->salt_iter = atoi ((const char *) iter_pos) - 1; + salt->salt_iter = atoll ((const char *) iter_pos) - 1; return (PARSER_OK); } @@ -6702,7 +6702,7 @@ int cloudkey_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U // iteration - salt->salt_iter = atoi ((const char *) iteration_pos) - 1; + salt->salt_iter = atoll ((const char *) iteration_pos) - 1; // data @@ -6842,7 +6842,7 @@ int nsec3_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUS // iteration - salt->salt_iter = atoi ((const char *) iteration_pos); + salt->salt_iter = atoll ((const char *) iteration_pos); return (PARSER_OK); } @@ -7127,7 +7127,7 @@ int lotus8_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU tmp_iter_buf[10] = 0; - salt->salt_iter = atoi ((const char *) tmp_iter_buf); + salt->salt_iter = atoll ((const char *) tmp_iter_buf); if (salt->salt_iter < 1) // well, the limit hopefully is much higher { @@ -7483,7 +7483,7 @@ int scrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU N_pos++; - salt->scrypt_N = atoi ((const char *) N_pos); + salt->scrypt_N = atoll ((const char *) N_pos); // r @@ -7493,7 +7493,7 @@ int scrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU r_pos++; - salt->scrypt_r = atoi ((const char *) r_pos); + salt->scrypt_r = atoll ((const char *) r_pos); // p @@ -7503,7 +7503,7 @@ int scrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU p_pos++; - salt->scrypt_p = atoi ((const char *) p_pos); + salt->scrypt_p = atoll ((const char *) p_pos); // salt @@ -7796,21 +7796,21 @@ int office2007_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE if (encryptedVerifierHash_len != 40) return (PARSER_SALT_LENGTH); - const u32 version = atoi ((const char *) version_pos); + const u32 version = atoll ((const char *) version_pos); if (version != 2007) return (PARSER_SALT_VALUE); - const u32 verifierHashSize = atoi ((const char *) verifierHashSize_pos); + const u32 verifierHashSize = atoll ((const char *) verifierHashSize_pos); if (verifierHashSize != 20) return (PARSER_SALT_VALUE); - const u32 keySize = atoi ((const char *) keySize_pos); + const u32 keySize = atoll ((const char *) keySize_pos); if ((keySize != 128) && (keySize != 256)) return (PARSER_SALT_VALUE); office2007->keySize = keySize; - const u32 saltSize = atoi ((const char *) saltSize_pos); + const u32 saltSize = atoll ((const char *) saltSize_pos); if (saltSize != 16) return (PARSER_SALT_VALUE); @@ -7935,19 +7935,19 @@ int office2010_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE if (encryptedVerifierHash_len != 64) return (PARSER_SALT_LENGTH); - const u32 version = atoi ((const char *) version_pos); + const u32 version = atoll ((const char *) version_pos); if (version != 2010) return (PARSER_SALT_VALUE); - const u32 spinCount = atoi ((const char *) spinCount_pos); + const u32 spinCount = atoll ((const char *) spinCount_pos); if (spinCount != 100000) return (PARSER_SALT_VALUE); - const u32 keySize = atoi ((const char *) keySize_pos); + const u32 keySize = atoll ((const char *) keySize_pos); if (keySize != 128) return (PARSER_SALT_VALUE); - const u32 saltSize = atoi ((const char *) saltSize_pos); + const u32 saltSize = atoll ((const char *) saltSize_pos); if (saltSize != 16) return (PARSER_SALT_VALUE); @@ -8075,19 +8075,19 @@ int office2013_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE if (encryptedVerifierHash_len != 64) return (PARSER_SALT_LENGTH); - const u32 version = atoi ((const char *) version_pos); + const u32 version = atoll ((const char *) version_pos); if (version != 2013) return (PARSER_SALT_VALUE); - const u32 spinCount = atoi ((const char *) spinCount_pos); + const u32 spinCount = atoll ((const char *) spinCount_pos); if (spinCount != 100000) return (PARSER_SALT_VALUE); - const u32 keySize = atoi ((const char *) keySize_pos); + const u32 keySize = atoll ((const char *) keySize_pos); if (keySize != 256) return (PARSER_SALT_VALUE); - const u32 saltSize = atoi ((const char *) saltSize_pos); + const u32 saltSize = atoll ((const char *) saltSize_pos); if (saltSize != 16) return (PARSER_SALT_VALUE); @@ -8970,7 +8970,7 @@ int saph_sha1_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_ u8 *iter_pos = input_buf + 10; - u32 iter = atoi ((const char *) iter_pos); + u32 iter = atoll ((const char *) iter_pos); if (iter < 1) { @@ -9918,9 +9918,9 @@ int pdf17l8_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN if ((enc_md != 0) && (enc_md != 1)) return (PARSER_SALT_VALUE); - const u32 id_len = atoi ((const char *) id_len_pos); - const u32 u_len = atoi ((const char *) u_len_pos); - const u32 o_len = atoi ((const char *) o_len_pos); + const u32 id_len = atoll ((const char *) id_len_pos); + const u32 u_len = atoll ((const char *) u_len_pos); + const u32 o_len = atoll ((const char *) o_len_pos); if (V_len > 6) return (PARSER_SALT_LENGTH); if (R_len > 6) return (PARSER_SALT_LENGTH); @@ -9985,7 +9985,7 @@ int pbkdf2_sha256_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MA u8 *iter_pos = input_buf + 7; - u32 iter = atoi ((const char *) iter_pos); + u32 iter = atoll ((const char *) iter_pos); if (iter < 1) return (PARSER_SALT_ITERATION); if (iter > 999999) return (PARSER_SALT_ITERATION); @@ -10293,10 +10293,10 @@ int bitcoin_wallet_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, M u32 public_key_buf_len = input_len - 1 - 7 - 1 - cry_master_len_len - 1 - cry_master_buf_len - 1 - cry_salt_len_len - 1 - cry_salt_buf_len - 1 - cry_rounds_len - 1 - ckey_len_len - 1 - ckey_buf_len - 1 - public_key_len_len - 1; - const u32 cry_master_len = atoi ((const char *) cry_master_len_pos); - const u32 cry_salt_len = atoi ((const char *) cry_salt_len_pos); - const u32 ckey_len = atoi ((const char *) ckey_len_pos); - const u32 public_key_len = atoi ((const char *) public_key_len_pos); + const u32 cry_master_len = atoll ((const char *) cry_master_len_pos); + const u32 cry_salt_len = atoll ((const char *) cry_salt_len_pos); + const u32 ckey_len = atoll ((const char *) ckey_len_pos); + const u32 public_key_len = atoll ((const char *) public_key_len_pos); if (cry_master_buf_len != cry_master_len) return (PARSER_SALT_VALUE); if (cry_salt_buf_len != cry_salt_len) return (PARSER_SALT_VALUE); @@ -10343,7 +10343,7 @@ int bitcoin_wallet_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, M if (cry_rounds_len >= 7) return (PARSER_SALT_VALUE); - const u32 cry_rounds = atoi ((const char *) cry_rounds_pos); + const u32 cry_rounds = atoll ((const char *) cry_rounds_pos); salt->salt_iter = cry_rounds - 1; @@ -10828,13 +10828,13 @@ int seven_zip_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_ u32 data_buf_len = input_len - 1 - 2 - 1 - p_buf_len - 1 - NumCyclesPower_len - 1 - salt_len_len - 1 - salt_buf_len - 1 - iv_len_len - 1 - iv_buf_len - 1 - crc_buf_len - 1 - data_len_len - 1 - unpack_size_len - 1; - const u32 iter = atoi ((const char *) NumCyclesPower_pos); - const u32 crc = atoi ((const char *) crc_buf_pos); - const u32 p_buf = atoi ((const char *) p_buf_pos); - const u32 salt_len = atoi ((const char *) salt_len_pos); - const u32 iv_len = atoi ((const char *) iv_len_pos); - const u32 unpack_size = atoi ((const char *) unpack_size_pos); - const u32 data_len = atoi ((const char *) data_len_pos); + const u32 iter = atoll ((const char *) NumCyclesPower_pos); + const u32 crc = atoll ((const char *) crc_buf_pos); + const u32 p_buf = atoll ((const char *) p_buf_pos); + const u32 salt_len = atoll ((const char *) salt_len_pos); + const u32 iv_len = atoll ((const char *) iv_len_pos); + const u32 unpack_size = atoll ((const char *) unpack_size_pos); + const u32 data_len = atoll ((const char *) data_len_pos); /** * verify some data @@ -10992,7 +10992,7 @@ int pbkdf2_md5_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE u8 *iter_pos = input_buf + 4; - u32 iter = atoi ((const char *) iter_pos); + u32 iter = atoll ((const char *) iter_pos); if (iter < 1) return (PARSER_SALT_ITERATION); if (iter > 999999) return (PARSER_SALT_ITERATION); @@ -11074,7 +11074,7 @@ int pbkdf2_sha1_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYB u8 *iter_pos = input_buf + 5; - u32 iter = atoi ((const char *) iter_pos); + u32 iter = atoll ((const char *) iter_pos); if (iter < 1) return (PARSER_SALT_ITERATION); if (iter > 999999) return (PARSER_SALT_ITERATION); @@ -11161,7 +11161,7 @@ int pbkdf2_sha512_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MA u8 *iter_pos = input_buf + 7; - u32 iter = atoi ((const char *) iter_pos); + u32 iter = atoll ((const char *) iter_pos); if (iter < 1) return (PARSER_SALT_ITERATION); if (iter > 999999) return (PARSER_SALT_ITERATION); @@ -11473,9 +11473,9 @@ int rar5_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE u8 *iv = param3_pos; u8 *pswcheck = param5_pos; - const u32 salt_len = atoi ((const char *) param0_pos); - const u32 iterations = atoi ((const char *) param2_pos); - const u32 pswcheck_len = atoi ((const char *) param4_pos); + const u32 salt_len = atoll ((const char *) param0_pos); + const u32 iterations = atoll ((const char *) param2_pos); + const u32 pswcheck_len = atoll ((const char *) param4_pos); /** * verify some data @@ -11643,7 +11643,7 @@ int axcrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN u8 *data_pos; - salt->salt_iter = atoi ((const char *) wrapping_rounds_pos); + salt->salt_iter = atoll ((const char *) wrapping_rounds_pos); salt_pos = (u8 *) strchr ((const char *) wrapping_rounds_pos, '*'); @@ -11738,7 +11738,7 @@ int keepass_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN version_pos = input_buf + 8 + 1 + 1; - keepass->version = atoi ((const char *) version_pos); + keepass->version = atoll ((const char *) version_pos); rounds_pos = (u8 *) strchr ((const char *) version_pos, '*'); @@ -11746,7 +11746,7 @@ int keepass_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN rounds_pos++; - salt->salt_iter = (atoi ((const char *) rounds_pos)); + salt->salt_iter = (atoll ((const char *) rounds_pos)); algorithm_pos = (u8 *) strchr ((const char *) rounds_pos, '*'); @@ -11754,7 +11754,7 @@ int keepass_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN algorithm_pos++; - keepass->algorithm = atoi ((const char *) algorithm_pos); + keepass->algorithm = atoll ((const char *) algorithm_pos); final_random_seed_pos = (u8 *) strchr ((const char *) algorithm_pos, '*'); @@ -11842,7 +11842,7 @@ int keepass_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN inline_flag_pos++; - u32 inline_flag = atoi ((const char *) inline_flag_pos); + u32 inline_flag = atoll ((const char *) inline_flag_pos); if (inline_flag != 1) return (PARSER_SALT_LENGTH); @@ -12109,7 +12109,7 @@ int mywallet_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U if (data_buf_len % 16) return (PARSER_HASH_LENGTH); - u32 data_len = atoi ((const char *) data_len_pos); + u32 data_len = atoll ((const char *) data_len_pos); if ((data_len * 2) != data_buf_len) return (PARSER_HASH_LENGTH); @@ -12203,7 +12203,7 @@ int ms_drsr_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN salt->salt_len = salt_len / 2; - salt->salt_iter = atoi ((const char *) iter_pos) - 1u; + salt->salt_iter = atoll ((const char *) iter_pos) - 1u; /** * digest buf @@ -12359,15 +12359,15 @@ int zip2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE param8_pos++; - const u32 type = atoi ((const char *) param0_pos); - const u32 mode = atoi ((const char *) param1_pos); - const u32 magic = atoi ((const char *) param2_pos); + const u32 type = atoll ((const char *) param0_pos); + const u32 mode = atoll ((const char *) param1_pos); + const u32 magic = atoll ((const char *) param2_pos); u8 *salt_buf = param3_pos; u32 verify_bytes; sscanf ((const char *) param4_pos, "%4x*", &verify_bytes); - const u32 compress_length = atoi ((const char *) param5_pos); + const u32 compress_length = atoll ((const char *) param5_pos); u8 *data_buf = param6_pos; u8 *auth = param7_pos; From 03efea645fbe1426c56f0db7df7ecb01b1fff926 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Wed, 16 Nov 2016 21:17:28 -0800 Subject: [PATCH 3/3] More sign fixes --- src/convert.c | 16 ++++---- src/cpu_crc32.c | 6 +-- src/dictstat.c | 2 +- src/filehandling.c | 2 +- src/folder.c | 6 +-- src/interface.c | 92 +++++++++++++++++++++++----------------------- 6 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/convert.c b/src/convert.c index 5914098df..16368b05d 100644 --- a/src/convert.c +++ b/src/convert.c @@ -203,14 +203,14 @@ void bin_to_hex_lower (const u32 v, u8 hex[8]) u32 add; - hex[0] += 6; add = ((hex[0] & 0x10) >> 4) * 39; hex[0] += 42 + add; - hex[1] += 6; add = ((hex[1] & 0x10) >> 4) * 39; hex[1] += 42 + add; - hex[2] += 6; add = ((hex[2] & 0x10) >> 4) * 39; hex[2] += 42 + add; - hex[3] += 6; add = ((hex[3] & 0x10) >> 4) * 39; hex[3] += 42 + add; - hex[4] += 6; add = ((hex[4] & 0x10) >> 4) * 39; hex[4] += 42 + add; - hex[5] += 6; add = ((hex[5] & 0x10) >> 4) * 39; hex[5] += 42 + add; - hex[6] += 6; add = ((hex[6] & 0x10) >> 4) * 39; hex[6] += 42 + add; - hex[7] += 6; add = ((hex[7] & 0x10) >> 4) * 39; hex[7] += 42 + add; + hex[0] += 6; add = ((hex[0] & 0x10u) >> 4) * 39; hex[0] += 42 + add; + hex[1] += 6; add = ((hex[1] & 0x10u) >> 4) * 39; hex[1] += 42 + add; + hex[2] += 6; add = ((hex[2] & 0x10u) >> 4) * 39; hex[2] += 42 + add; + hex[3] += 6; add = ((hex[3] & 0x10u) >> 4) * 39; hex[3] += 42 + add; + hex[4] += 6; add = ((hex[4] & 0x10u) >> 4) * 39; hex[4] += 42 + add; + hex[5] += 6; add = ((hex[5] & 0x10u) >> 4) * 39; hex[5] += 42 + add; + hex[6] += 6; add = ((hex[6] & 0x10u) >> 4) * 39; hex[6] += 42 + add; + hex[7] += 6; add = ((hex[7] & 0x10u) >> 4) * 39; hex[7] += 42 + add; } u8 int_to_base32 (const u8 c) diff --git a/src/cpu_crc32.c b/src/cpu_crc32.c index 36a62919d..1a4b2568f 100644 --- a/src/cpu_crc32.c +++ b/src/cpu_crc32.c @@ -94,13 +94,13 @@ int cpu_crc32 (hashcat_ctx_t *hashcat_ctx, const char *filename, u8 keytab[64]) u8 *buf = (u8 *) hcmalloc (hashcat_ctx, MAX_KEY_SIZE + 1); VERIFY_PTR (buf); - int nread = fread (buf, sizeof (u8), MAX_KEY_SIZE, fd); + size_t nread = fread (buf, sizeof (u8), MAX_KEY_SIZE, fd); fclose (fd); - int kpos = 0; + size_t kpos = 0; - for (int fpos = 0; fpos < nread; fpos++) + for (size_t fpos = 0; fpos < nread; fpos++) { crc = crc32tab[(crc ^ buf[fpos]) & 0xff] ^ (crc >> 8); diff --git a/src/dictstat.c b/src/dictstat.c index a331109fc..1b28eb0f0 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -94,7 +94,7 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx) { dictstat_t d; - const int nread = fread (&d, sizeof (dictstat_t), 1, fp); + const size_t nread = fread (&d, sizeof (dictstat_t), 1, fp); if (nread == 0) continue; diff --git a/src/filehandling.c b/src/filehandling.c index 67218dba2..b2d6a5968 100644 --- a/src/filehandling.c +++ b/src/filehandling.c @@ -79,7 +79,7 @@ int fgetl (FILE *fp, char *line_buf) int in_superchop (char *buf) { - int len = strlen (buf); + size_t len = strlen (buf); while (len) { diff --git a/src/folder.c b/src/folder.c index 1b2bee377..258ce2c55 100644 --- a/src/folder.c +++ b/src/folder.c @@ -30,11 +30,11 @@ static int get_exec_path (char *exec_path, const size_t exec_path_sz) snprintf (tmp, sizeof (tmp) - 1, "/proc/%d/exe", getpid ()); - const int len = readlink (tmp, exec_path, exec_path_sz - 1); + const ssize_t len = readlink (tmp, exec_path, exec_path_sz - 1); #elif defined (_WIN) - const int len = GetModuleFileName (NULL, exec_path, exec_path_sz - 1); + const DWORD len = GetModuleFileName (NULL, exec_path, exec_path_sz - 1); #elif defined (__APPLE__) @@ -59,7 +59,7 @@ static int get_exec_path (char *exec_path, const size_t exec_path_sz) sysctl (mib, 4, exec_path, &size, NULL, 0); - const int len = readlink (tmp, exec_path, exec_path_sz - 1); + const ssize_t len = readlink (tmp, exec_path, exec_path_sz - 1); #else #error Your Operating System is not supported or detected diff --git a/src/interface.c b/src/interface.c index ddf38221a..1fcd7a20c 100644 --- a/src/interface.c +++ b/src/interface.c @@ -2399,7 +2399,7 @@ int netscreen_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_ // unscramble - char clean_input_buf[32] = { 0 }; + u8 clean_input_buf[32] = { 0 }; char sig[6] = { 'n', 'r', 'c', 's', 't', 'n' }; int pos[6] = { 0, 6, 12, 17, 23, 29 }; @@ -2746,7 +2746,7 @@ int psafe2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU memset (&buf, 0, sizeof (psafe2_hdr)); - int n = fread (&buf, sizeof (psafe2_hdr), 1, fp); + size_t n = fread (&buf, sizeof (psafe2_hdr), 1, fp); fclose (fp); @@ -2781,7 +2781,7 @@ int psafe3_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU psafe3_t in; - int n = fread (&in, sizeof (psafe3_t), 1, fp); + size_t n = fread (&in, sizeof (psafe3_t), 1, fp); fclose (fp); @@ -3219,7 +3219,7 @@ int md5asa_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU if ((input_len < DISPLAY_LEN_MIN_2410) || (input_len > DISPLAY_LEN_MAX_2410)) return (PARSER_GLOBAL_LENGTH); } - u32 *digest = (u32 *) hash_buf->digest; + int *digest = (int *) hash_buf->digest; salt_t *salt = hash_buf->salt; @@ -3392,8 +3392,8 @@ int netntlmv1_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_ for (u32 i = 0; i < srvchall_len; i += 2) { - const char p0 = srvchall_pos[i + 0]; - const char p1 = srvchall_pos[i + 1]; + const u8 p0 = srvchall_pos[i + 0]; + const u8 p1 = srvchall_pos[i + 1]; *chall_ptr++ = hex_convert (p1) << 0 | hex_convert (p0) << 4; @@ -3405,8 +3405,8 @@ int netntlmv1_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_ for (u32 i = 0; i < clichall_len; i += 2) { - const char p0 = clichall_pos[i + 0]; - const char p1 = clichall_pos[i + 1]; + const u8 p0 = clichall_pos[i + 0]; + const u8 p1 = clichall_pos[i + 1]; *chall_ptr++ = hex_convert (p1) << 0 | hex_convert (p0) << 4; @@ -3632,8 +3632,8 @@ int netntlmv2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_ for (u32 i = 0; i < srvchall_len; i += 2) { - const char p0 = srvchall_pos[i + 0]; - const char p1 = srvchall_pos[i + 1]; + const u8 p0 = srvchall_pos[i + 0]; + const u8 p1 = srvchall_pos[i + 1]; *chall_ptr++ = hex_convert (p1) << 0 | hex_convert (p0) << 4; @@ -3645,8 +3645,8 @@ int netntlmv2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_ for (u32 i = 0; i < clichall_len; i += 2) { - const char p0 = clichall_pos[i + 0]; - const char p1 = clichall_pos[i + 1]; + const u8 p0 = clichall_pos[i + 0]; + const u8 p1 = clichall_pos[i + 1]; *chall_ptr++ = hex_convert (p1) << 0 | hex_convert (p0) << 4; @@ -5057,7 +5057,7 @@ int truecrypt_parse_hash_1k (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAY char buf[512] = { 0 }; - int n = fread (buf, 1, sizeof (buf), fp); + size_t n = fread (buf, 1, sizeof (buf), fp); fclose (fp); @@ -5096,7 +5096,7 @@ int truecrypt_parse_hash_2k (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAY char buf[512] = { 0 }; - int n = fread (buf, 1, sizeof (buf), fp); + size_t n = fread (buf, 1, sizeof (buf), fp); fclose (fp); @@ -5135,7 +5135,7 @@ int veracrypt_parse_hash_200000 (u8 *input_buf, u32 input_len, hash_t *hash_buf, char buf[512] = { 0 }; - int n = fread (buf, 1, sizeof (buf), fp); + size_t n = fread (buf, 1, sizeof (buf), fp); fclose (fp); @@ -5174,7 +5174,7 @@ int veracrypt_parse_hash_500000 (u8 *input_buf, u32 input_len, hash_t *hash_buf, char buf[512] = { 0 }; - int n = fread (buf, 1, sizeof (buf), fp); + size_t n = fread (buf, 1, sizeof (buf), fp); fclose (fp); @@ -5213,7 +5213,7 @@ int veracrypt_parse_hash_327661 (u8 *input_buf, u32 input_len, hash_t *hash_buf, char buf[512] = { 0 }; - int n = fread (buf, 1, sizeof (buf), fp); + size_t n = fread (buf, 1, sizeof (buf), fp); fclose (fp); @@ -5252,7 +5252,7 @@ int veracrypt_parse_hash_655331 (u8 *input_buf, u32 input_len, hash_t *hash_buf, char buf[512] = { 0 }; - int n = fread (buf, 1, sizeof (buf), fp); + size_t n = fread (buf, 1, sizeof (buf), fp); fclose (fp); @@ -5338,7 +5338,7 @@ int sha1aix_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN salt->salt_len = salt_len; - char salt_iter[3] = { iter_pos[0], iter_pos[1], 0 }; + u8 salt_iter[3] = { iter_pos[0], iter_pos[1], 0 }; salt->salt_sign[0] = atoll ((const char *) salt_iter); @@ -5515,8 +5515,8 @@ int agilekey_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U for (u32 i = 0; i < saltbuf_len; i += 2) { - const char p0 = saltbuf_pos[i + 0]; - const char p1 = saltbuf_pos[i + 1]; + const u8 p0 = saltbuf_pos[i + 0]; + const u8 p1 = saltbuf_pos[i + 1]; *saltbuf_ptr++ = hex_convert (p1) << 0 | hex_convert (p0) << 4; @@ -5534,8 +5534,8 @@ int agilekey_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U for (u32 i = 2016; i < cipherbuf_len; i += 2) { - const char p0 = cipherbuf_pos[i + 0]; - const char p1 = cipherbuf_pos[i + 1]; + const u8 p0 = cipherbuf_pos[i + 0]; + const u8 p1 = cipherbuf_pos[i + 1]; *cipherbuf_ptr++ = hex_convert (p1) << 0 | hex_convert (p0) << 4; @@ -5556,8 +5556,8 @@ int agilekey_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U for (u32 i = 0, j = 0; i < 1040; i += 1, j += 2) { - const char p0 = cipherbuf_pos[j + 0]; - const char p1 = cipherbuf_pos[j + 1]; + const u8 p0 = cipherbuf_pos[j + 0]; + const u8 p1 = cipherbuf_pos[j + 1]; agilekey->cipher[i] = hex_convert (p1) << 0 | hex_convert (p0) << 4; @@ -6178,8 +6178,8 @@ int krb5pa_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU for (u32 i = 0; i < (36 * 2); i += 2) { - const char p0 = data_pos[i + 0]; - const char p1 = data_pos[i + 1]; + const u8 p0 = data_pos[i + 0]; + const u8 p1 = data_pos[i + 1]; *timestamp_ptr++ = hex_convert (p1) << 0 | hex_convert (p0) << 4; @@ -6189,8 +6189,8 @@ int krb5pa_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU for (u32 i = (36 * 2); i < ((36 + 16) * 2); i += 2) { - const char p0 = data_pos[i + 0]; - const char p1 = data_pos[i + 1]; + const u8 p0 = data_pos[i + 0]; + const u8 p1 = data_pos[i + 1]; *checksum_ptr++ = hex_convert (p1) << 0 | hex_convert (p0) << 4; @@ -6688,8 +6688,8 @@ int cloudkey_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U for (u32 i = 0; i < saltbuf_len; i += 2) { - const char p0 = saltbuf_pos[i + 0]; - const char p1 = saltbuf_pos[i + 1]; + const u8 p0 = saltbuf_pos[i + 0]; + const u8 p1 = saltbuf_pos[i + 1]; *saltbuf_ptr++ = hex_convert (p1) << 0 | hex_convert (p0) << 4; @@ -6710,8 +6710,8 @@ int cloudkey_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U for (u32 i = 0; i < databuf_len; i += 2) { - const char p0 = databuf_pos[i + 0]; - const char p1 = databuf_pos[i + 1]; + const u8 p0 = databuf_pos[i + 0]; + const u8 p1 = databuf_pos[i + 1]; *databuf_ptr++ = hex_convert (p1) << 0 | hex_convert (p0) << 4; @@ -11582,8 +11582,8 @@ int krb5tgs_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN for (u32 i = 0; i < 16 * 2; i += 2) { - const char p0 = data_pos[i + 0]; - const char p1 = data_pos[i + 1]; + const u8 p0 = data_pos[i + 0]; + const u8 p1 = data_pos[i + 1]; *checksum_ptr++ = hex_convert (p1) << 0 | hex_convert (p0) << 4; @@ -11596,8 +11596,8 @@ int krb5tgs_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN /* skip '$' */ for (u32 i = 16 * 2 + 1; i < (krb5tgs->edata2_len * 2) + (16 * 2 + 1); i += 2) { - const char p0 = data_pos[i + 0]; - const char p1 = data_pos[i + 1]; + const u8 p0 = data_pos[i + 0]; + const u8 p1 = data_pos[i + 1]; *edata_ptr++ = hex_convert (p1) << 0 | hex_convert (p0) << 4; } @@ -12451,8 +12451,8 @@ int zip2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE for (u32 i = 0; i < param6_len; i += 2) { - const char p0 = data_buf[i + 0]; - const char p1 = data_buf[i + 1]; + const u8 p0 = data_buf[i + 0]; + const u8 p1 = data_buf[i + 1]; *data_buf_ptr++ = hex_convert (p1) << 0 | hex_convert (p0) << 4; @@ -12466,8 +12466,8 @@ int zip2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE for (u32 i = 0; i < param7_len; i += 2) { - const char p0 = auth[i + 0]; - const char p1 = auth[i + 1]; + const u8 p0 = auth[i + 0]; + const u8 p1 = auth[i + 1]; *auth_ptr++ = hex_convert (p1) << 0 | hex_convert (p0) << 4; @@ -13241,7 +13241,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, char tmp_buf[1024] = { 0 }; char *ptr_plain = (char *) out_buf_plain; - char *ptr_salt = (char *) out_buf_salt; + u8 *ptr_salt = (u8 *) out_buf_salt; if (hash_mode == 22) { @@ -13757,7 +13757,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, ikepsk_t *ikepsk = &ikepsks[salt_pos]; - int buf_len = len - 1; + size_t buf_len = len - 1; // msg_buf @@ -13823,7 +13823,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, ikepsk_t *ikepsk = &ikepsks[salt_pos]; - int buf_len = len - 1; + size_t buf_len = len - 1; // msg_buf @@ -14782,7 +14782,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, // response - u32 tmp_len = snprintf (tmp_buf, sizeof (tmp_buf) - 1, "%s %08x%08x%08x%08x", + int tmp_len = snprintf (tmp_buf, sizeof (tmp_buf) - 1, "%s %08x%08x%08x%08x", (char *) cram_md5->user, digest_buf[0], digest_buf[1], @@ -15253,7 +15253,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, { // encode iteration count - char salt_iter[5] = { 0 }; + u8 salt_iter[5] = { 0 }; salt_iter[0] = int_to_itoa64 ((salt.salt_iter ) & 0x3f); salt_iter[1] = int_to_itoa64 ((salt.salt_iter >> 6) & 0x3f);