From 074fad9fef9a4dee89f615de5ccd9e1d32673e19 Mon Sep 17 00:00:00 2001 From: "R. Yushaev" <44146334+Naufragous@users.noreply.github.com> Date: Fri, 7 Dec 2018 10:37:56 +0100 Subject: [PATCH] Correct buffer size parameter in snprintf calls There are approx. 240 snprintf calls that set the target buffer size to out_len - 1 or similar. This "mind the null character" subtraction is unnecessary since snprintf already includes the string termination into the given buffer size. --- src/brain.c | 8 +- src/folder.c | 4 +- src/hwmon.c | 4 +- src/interface.c | 364 ++++++++++++++++++++++++------------------------ src/opencl.c | 60 ++++---- src/status.c | 42 +++--- 6 files changed, 241 insertions(+), 241 deletions(-) diff --git a/src/brain.c b/src/brain.c index b53e91f75..5e2470232 100644 --- a/src/brain.c +++ b/src/brain.c @@ -921,7 +921,7 @@ bool brain_client_connect (hc_device_param_t *device_param, const status_ctx_t * char port_str[8]; - snprintf (port_str, sizeof (port_str) - 1, "%i", port); + snprintf (port_str, sizeof (port_str), "%i", port); const char *host_real = (host == NULL) ? "127.0.0.1" : (const char *) host; @@ -1563,7 +1563,7 @@ bool brain_server_write_hash_dumps (brain_server_dbs_t *brain_server_dbs, const char file[100]; - snprintf (file, sizeof (file) - 1, "%s/brain.%08x.ldmp", path, brain_server_db_hash->brain_session); + snprintf (file, sizeof (file), "%s/brain.%08x.ldmp", path, brain_server_db_hash->brain_session); brain_server_write_hash_dump (brain_server_db_hash, file); @@ -1762,7 +1762,7 @@ bool brain_server_write_attack_dumps (brain_server_dbs_t *brain_server_dbs, cons char file[100]; - snprintf (file, sizeof (file) - 1, "%s/brain.%08x.admp", path, brain_server_db_attack->brain_attack); + snprintf (file, sizeof (file), "%s/brain.%08x.admp", path, brain_server_db_attack->brain_attack); brain_server_write_attack_dump (brain_server_db_attack, file); @@ -2972,7 +2972,7 @@ int brain_server (const char *listen_host, const int listen_port, const char *br auth_password = (char *) hcmalloc (BRAIN_PASSWORD_SZ); - snprintf (auth_password, BRAIN_PASSWORD_SZ - 1, "%08x%08x", brain_auth_challenge (), brain_auth_challenge ()); + snprintf (auth_password, BRAIN_PASSWORD_SZ, "%08x%08x", brain_auth_challenge (), brain_auth_challenge ()); brain_logging (stdout, 0, "Generated authentication password: %s\n", auth_password); } diff --git a/src/folder.c b/src/folder.c index a3c9a7303..003132383 100644 --- a/src/folder.c +++ b/src/folder.c @@ -100,12 +100,12 @@ static void get_install_dir (char *install_dir, const char *exec_path) #if defined (_POSIX) static void get_profile_dir (char *profile_dir, const char *home_dir) { - snprintf (profile_dir, HCBUFSIZ_TINY - 1, "%s/%s", home_dir, DOT_HASHCAT); + snprintf (profile_dir, HCBUFSIZ_TINY, "%s/%s", home_dir, DOT_HASHCAT); } static void get_session_dir (char *session_dir, const char *profile_dir) { - snprintf (session_dir, HCBUFSIZ_TINY - 1, "%s/%s", profile_dir, SESSIONS_FOLDER); + snprintf (session_dir, HCBUFSIZ_TINY, "%s/%s", profile_dir, SESSIONS_FOLDER); } #endif diff --git a/src/hwmon.c b/src/hwmon.c index dc02a8311..46fc8a9fb 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -71,7 +71,7 @@ static char *hm_SYSFS_get_syspath_hwmon (hashcat_ctx_t *hashcat_ctx, const int d char *hwmon = hcmalloc (HCBUFSIZ_TINY); - snprintf (hwmon, HCBUFSIZ_TINY - 1, "%s/hwmon", syspath); + snprintf (hwmon, HCBUFSIZ_TINY, "%s/hwmon", syspath); char *hwmonN = first_file_in_directory (hwmon); @@ -87,7 +87,7 @@ static char *hm_SYSFS_get_syspath_hwmon (hashcat_ctx_t *hashcat_ctx, const int d return NULL; } - snprintf (hwmon, HCBUFSIZ_TINY - 1, "%s/hwmon/%s", syspath, hwmonN); + snprintf (hwmon, HCBUFSIZ_TINY, "%s/hwmon/%s", syspath, hwmonN); hcfree (syspath); diff --git a/src/interface.c b/src/interface.c index 20314e1d9..88d6fb6d2 100644 --- a/src/interface.c +++ b/src/interface.c @@ -13245,7 +13245,7 @@ int sip_auth_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U u8 tmp[64]; - snprintf ((char *) tmp, sizeof (tmp) - 1, "%08x%08x%08x%08x", + snprintf ((char *) tmp, sizeof (tmp), "%08x%08x%08x%08x", tmp_digest[0], tmp_digest[1], tmp_digest[2], @@ -19681,7 +19681,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le tmp_buf[28] = int_to_base64 (((ptr[6]) >> 0) & 0x3f); tmp_buf[29] = sig[5]; - snprintf (out_buf, out_len - 1, "%s:%s", + snprintf (out_buf, out_len, "%s:%s", tmp_buf, username); } @@ -19693,7 +19693,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le salt_buf_ptr[salt.salt_len - 8] = 0; - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x:%s", + snprintf (out_buf, out_len, "%08x%08x%08x%08x:%s", digest_buf[0], digest_buf[1], digest_buf[2], @@ -19714,7 +19714,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le base64_encode (int_to_base64, (const u8 *) tmp_buf, 20, (u8 *) ptr_plain); - snprintf (out_buf, out_len - 1, "{SHA}%s", ptr_plain); + snprintf (out_buf, out_len, "{SHA}%s", ptr_plain); } else if (hash_mode == 111) { @@ -19731,11 +19731,11 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le base64_encode (int_to_base64, (const u8 *) tmp_buf, 20 + salt.salt_len, (u8 *) ptr_plain); - snprintf (out_buf, out_len - 1, "{SSHA}%s", ptr_plain); + snprintf (out_buf, out_len, "{SSHA}%s", ptr_plain); } else if (hash_mode == 112) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x:%s", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x:%s", digest_buf[0], digest_buf[1], digest_buf[2], @@ -19745,7 +19745,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if ((hash_mode == 122) || (hash_mode == 125)) { - snprintf (out_buf, out_len - 1, "%s%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%08x%08x%08x%08x%08x", (char *) salt.salt_buf, digest_buf[0], digest_buf[1], @@ -19755,7 +19755,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 124) { - snprintf (out_buf, out_len - 1, "sha1$%s$%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "sha1$%s$%08x%08x%08x%08x%08x", (char *) salt.salt_buf, digest_buf[0], digest_buf[1], @@ -19765,7 +19765,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 131) { - snprintf (out_buf, out_len - 1, "0x0100%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "0x0100%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", (char *) salt.salt_buf, 0u, 0u, 0u, 0u, 0u, digest_buf[0], @@ -19776,7 +19776,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 132) { - snprintf (out_buf, out_len - 1, "0x0100%s%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "0x0100%s%08x%08x%08x%08x%08x", (char *) salt.salt_buf, digest_buf[0], digest_buf[1], @@ -19798,7 +19798,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le base64_encode (int_to_base64, (const u8 *) tmp_buf, 20, (u8 *) ptr_plain); - snprintf (out_buf, out_len - 1, "%s", ptr_plain); + snprintf (out_buf, out_len, "%s", ptr_plain); } else if (hash_mode == 141) { @@ -19822,7 +19822,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le ptr_plain[27] = 0; - snprintf (out_buf, out_len - 1, "%s*0*%s*%s", SIGNATURE_EPISERVER, ptr_salt, ptr_plain); + snprintf (out_buf, out_len, "%s*0*%s*%s", SIGNATURE_EPISERVER, ptr_salt, ptr_plain); } else if (hash_mode == 400) { @@ -19835,7 +19835,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le phpass_encode ((unsigned char *) digest_buf, (unsigned char *) ptr_plain); - snprintf (out_buf, out_len - 1, "%s%s%s", (char *) salt.salt_sign, (char *) salt.salt_buf, ptr_plain); + snprintf (out_buf, out_len, "%s%s%s", (char *) salt.salt_sign, (char *) salt.salt_buf, ptr_plain); } else if (hash_mode == 500) { @@ -19850,11 +19850,11 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le if (salt.salt_iter == ROUNDS_MD5CRYPT) { - snprintf (out_buf, out_len - 1, "$1$%s$%s", (char *) salt.salt_buf, ptr_plain); + snprintf (out_buf, out_len, "$1$%s$%s", (char *) salt.salt_buf, ptr_plain); } else { - snprintf (out_buf, out_len - 1, "$1$rounds=%u$%s$%s", salt.salt_iter, (char *) salt.salt_buf, ptr_plain); + snprintf (out_buf, out_len, "$1$rounds=%u$%s$%s", salt.salt_iter, (char *) salt.salt_buf, ptr_plain); } } else if (hash_mode == 501) @@ -19862,7 +19862,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le hashinfo_t **hashinfo_ptr = hash_info; char *hash_buf = hashinfo_ptr[digest_cur]->orighash; - snprintf (out_buf, out_len - 1, "%s", hash_buf); + snprintf (out_buf, out_len, "%s", hash_buf); } else if (hash_mode == 1411) { @@ -19882,13 +19882,13 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le base64_encode (int_to_base64, (const u8 *) tmp_buf, 32 + salt.salt_len, (u8 *) ptr_plain); - snprintf (out_buf, out_len - 1, "%s%s", SIGNATURE_SHA256B64S, ptr_plain); + snprintf (out_buf, out_len, "%s%s", SIGNATURE_SHA256B64S, ptr_plain); } else if (hash_mode == 1421) { u8 *salt_ptr = (u8 *) salt.salt_buf; - snprintf (out_buf, out_len - 1, "%c%c%c%c%c%c%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%c%c%c%c%c%c%08x%08x%08x%08x%08x%08x%08x%08x", salt_ptr[0], salt_ptr[1], salt_ptr[2], @@ -19929,7 +19929,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le ptr_plain[43] = 0; - snprintf (out_buf, out_len - 1, "%s*1*%s*%s", SIGNATURE_EPISERVER, ptr_salt, ptr_plain); + snprintf (out_buf, out_len, "%s*1*%s*%s", SIGNATURE_EPISERVER, ptr_salt, ptr_plain); } else if (hash_mode == 1500) { @@ -19950,7 +19950,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le base64_encode (int_to_itoa64, (const u8 *) tmp_buf, 8, (u8 *) ptr_plain); - snprintf (out_buf + 2, out_len - 1 - 2, "%s", ptr_plain); + snprintf (out_buf + 2, out_len - 2, "%s", ptr_plain); out_buf[13] = 0; } @@ -19967,11 +19967,11 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le if (salt.salt_iter == ROUNDS_MD5CRYPT) { - snprintf (out_buf, out_len - 1, "$apr1$%s$%s", (char *) salt.salt_buf, ptr_plain); + snprintf (out_buf, out_len, "$apr1$%s$%s", (char *) salt.salt_buf, ptr_plain); } else { - snprintf (out_buf, out_len - 1, "$apr1$rounds=%u$%s$%s", salt.salt_iter, (char *) salt.salt_buf, ptr_plain); + snprintf (out_buf, out_len, "$apr1$rounds=%u$%s$%s", salt.salt_iter, (char *) salt.salt_buf, ptr_plain); } } else if (hash_mode == 1711) @@ -19992,13 +19992,13 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le base64_encode (int_to_base64, (const u8 *) tmp_buf, 64 + salt.salt_len, (u8 *) ptr_plain); - snprintf (out_buf, out_len - 1, "%s%s", SIGNATURE_SHA512B64S, ptr_plain); + snprintf (out_buf, out_len, "%s%s", SIGNATURE_SHA512B64S, ptr_plain); } else if (hash_mode == 1722) { u32 *ptr = digest_buf; - snprintf (out_buf, out_len - 1, "%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", (unsigned char *) salt.salt_buf, ptr[ 1], ptr[ 0], ptr[ 3], ptr[ 2], @@ -20013,7 +20013,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le { u32 *ptr = digest_buf; - snprintf (out_buf, out_len - 1, "0x0200%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "0x0200%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", (unsigned char *) salt.salt_buf, ptr[ 1], ptr[ 0], ptr[ 3], ptr[ 2], @@ -20041,18 +20041,18 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le if (salt.salt_iter == ROUNDS_SHA512CRYPT) { - snprintf (out_buf, out_len - 1, "$6$%s$%s", (char *) salt.salt_buf, ptr_plain); + snprintf (out_buf, out_len, "$6$%s$%s", (char *) salt.salt_buf, ptr_plain); } else { - snprintf (out_buf, out_len - 1, "$6$rounds=%u$%s$%s", salt.salt_iter, (char *) salt.salt_buf, ptr_plain); + snprintf (out_buf, out_len, "$6$rounds=%u$%s$%s", salt.salt_iter, (char *) salt.salt_buf, ptr_plain); } } else if (hash_mode == 2100) { u32 pos = 0; - snprintf (out_buf + pos, out_len - 1 - pos, "%s%u#", + snprintf (out_buf + pos, out_len - pos, "%s%u#", SIGNATURE_DCC2, salt.salt_iter + 1); @@ -20062,9 +20062,9 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le char *salt_ptr = (char *) salt.salt_buf; - for (u32 i = 0; i < salt.salt_len; i++, pos++) snprintf (out_buf + pos, out_len - 1 - pos, "%c", salt_ptr[i]); + for (u32 i = 0; i < salt.salt_len; i++, pos++) snprintf (out_buf + pos, out_len - pos, "%c", salt_ptr[i]); - snprintf (out_buf + pos, out_len - 1 - pos, "#%08x%08x%08x%08x", + snprintf (out_buf + pos, out_len - pos, "#%08x%08x%08x%08x", byte_swap_32 (digest_buf[0]), byte_swap_32 (digest_buf[1]), byte_swap_32 (digest_buf[2]), @@ -20130,7 +20130,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le essid = tmp_buf; } - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x:%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s", + snprintf (out_buf, out_len, "%08x%08x%08x%08x:%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s", wpa_eapol->hash[0], wpa_eapol->hash[1], wpa_eapol->hash[2], @@ -20151,7 +20151,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 4400) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x", byte_swap_32 (digest_buf[0]), byte_swap_32 (digest_buf[1]), byte_swap_32 (digest_buf[2]), @@ -20159,7 +20159,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 4700) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x", byte_swap_32 (digest_buf[0]), byte_swap_32 (digest_buf[1]), byte_swap_32 (digest_buf[2]), @@ -20170,7 +20170,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le { u8 chap_id_byte = (u8) salt.salt_buf[4]; - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x:%08x%08x%08x%08x:%02x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x:%08x%08x%08x%08x:%02x", digest_buf[0], digest_buf[1], digest_buf[2], @@ -20183,7 +20183,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 4900) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x", byte_swap_32 (digest_buf[0]), byte_swap_32 (digest_buf[1]), byte_swap_32 (digest_buf[2]), @@ -20192,13 +20192,13 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 5100) { - snprintf (out_buf, out_len - 1, "%08x%08x", + snprintf (out_buf, out_len, "%08x%08x", digest_buf[0], digest_buf[1]); } else if (hash_mode == 5200) { - snprintf (out_buf, out_len - 1, "%s", hashfile); + snprintf (out_buf, out_len, "%s", hashfile); } else if (hash_mode == 5300) { @@ -20371,7 +20371,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le sprintf (clichall_buf + j, "%02x", ptr[netntlm->srvchall_len + i]); } - snprintf (out_buf, out_len - 1, "%s::%s:%s:%08x%08x%08x%08x%08x%08x:%s", + snprintf (out_buf, out_len, "%s::%s:%s:%08x%08x%08x%08x%08x%08x:%s", user_buf, domain_buf, srvchall_buf, @@ -20422,7 +20422,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le sprintf (clichall_buf + j, "%02x", ptr[netntlm->srvchall_len + i]); } - snprintf (out_buf, out_len - 1, "%s::%s:%s:%08x%08x%08x%08x:%s", + snprintf (out_buf, out_len, "%s::%s:%s:%08x%08x%08x%08x:%s", user_buf, domain_buf, srvchall_buf, @@ -20451,7 +20451,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le ptr_plain[43] = 0; - snprintf (out_buf, out_len - 1, "%s", ptr_plain); + snprintf (out_buf, out_len, "%s", ptr_plain); } else if (hash_mode == 5800) { @@ -20461,7 +20461,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le digest_buf[3] = byte_swap_32 (digest_buf[3]); digest_buf[4] = byte_swap_32 (digest_buf[4]); - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x", digest_buf[0], digest_buf[1], digest_buf[2], @@ -20470,7 +20470,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if ((hash_mode >= 6200) && (hash_mode <= 6299)) { - snprintf (out_buf, out_len - 1, "%s", hashfile); + snprintf (out_buf, out_len, "%s", hashfile); } else if (hash_mode == 6300) { @@ -20483,19 +20483,19 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le md5crypt_encode ((unsigned char *) digest_buf, (unsigned char *) ptr_plain); - snprintf (out_buf, out_len - 1, "{smd5}%s$%s", (char *) salt.salt_buf, ptr_plain); + snprintf (out_buf, out_len, "{smd5}%s$%s", (char *) salt.salt_buf, ptr_plain); } else if (hash_mode == 6400) { sha256aix_encode ((unsigned char *) digest_buf, (unsigned char *) ptr_plain); - snprintf (out_buf, out_len - 1, "{ssha256}%02u$%s$%s", salt.salt_sign[0], (char *) salt.salt_buf, ptr_plain); + snprintf (out_buf, out_len, "{ssha256}%02u$%s$%s", salt.salt_sign[0], (char *) salt.salt_buf, ptr_plain); } else if (hash_mode == 6500) { sha512aix_encode ((unsigned char *) digest_buf64, (unsigned char *) ptr_plain); - snprintf (out_buf, out_len - 1, "{ssha512}%02u$%s$%s", salt.salt_sign[0], (char *) salt.salt_buf, ptr_plain); + snprintf (out_buf, out_len, "{ssha512}%02u$%s$%s", salt.salt_sign[0], (char *) salt.salt_buf, ptr_plain); } else if (hash_mode == 6600) { @@ -20506,22 +20506,22 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le salt.salt_buf[0] = byte_swap_32 (salt.salt_buf[0]); salt.salt_buf[1] = byte_swap_32 (salt.salt_buf[1]); - u32 off = snprintf (out_buf, out_len - 1, "%u:%08x%08x:", salt.salt_iter + 1, salt.salt_buf[0], salt.salt_buf[1]); + u32 off = snprintf (out_buf, out_len, "%u:%08x%08x:", salt.salt_iter + 1, salt.salt_buf[0], salt.salt_buf[1]); for (u32 i = 0, j = off; i < 1040; i++, j += 2) { - snprintf (out_buf + j, out_len - 1 - j, "%02x", agilekey->cipher[i]); + snprintf (out_buf + j, out_len - j, "%02x", agilekey->cipher[i]); } } else if (hash_mode == 6700) { sha1aix_encode ((unsigned char *) digest_buf, (unsigned char *) ptr_plain); - snprintf (out_buf, out_len - 1, "{ssha1}%02u$%s$%s", salt.salt_sign[0], (char *) salt.salt_buf, ptr_plain); + snprintf (out_buf, out_len, "{ssha1}%02u$%s$%s", salt.salt_sign[0], (char *) salt.salt_buf, ptr_plain); } else if (hash_mode == 6800) { - snprintf (out_buf, out_len - 1, "%s", (char *) salt.salt_buf); + snprintf (out_buf, out_len, "%s", (char *) salt.salt_buf); } else if (hash_mode == 7000) { @@ -20539,7 +20539,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le ptr_plain[44] = 0; - snprintf (out_buf, out_len - 1, "%s%s", + snprintf (out_buf, out_len, "%s%s", SIGNATURE_FORTIGATE, ptr_plain); } @@ -20562,7 +20562,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le esalt[6] = byte_swap_32 (pbkdf2_sha512->salt_buf[6]); esalt[7] = byte_swap_32 (pbkdf2_sha512->salt_buf[7]); - snprintf (out_buf, out_len - 1, "%s%u$%08x%08x%08x%08x%08x%08x%08x%08x$%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%u$%08x%08x%08x%08x%08x%08x%08x%08x$%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", SIGNATURE_SHA512MACOS, salt.salt_iter + 1, esalt[ 0], esalt[ 1], @@ -20588,7 +20588,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le u32 len_used = 0; - snprintf (out_buf + len_used, out_len - 1 - len_used, "%s%u.", SIGNATURE_SHA512GRUB, salt.salt_iter + 1); + snprintf (out_buf + len_used, out_len - len_used, "%s%u.", SIGNATURE_SHA512GRUB, salt.salt_iter + 1); len_used = strlen (out_buf); @@ -20596,10 +20596,10 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le for (u32 i = 0; i < salt.salt_len; i++, len_used += 2) { - snprintf (out_buf + len_used, out_len - 1 - len_used, "%02x", salt_buf_ptr[i]); + snprintf (out_buf + len_used, out_len - len_used, "%02x", salt_buf_ptr[i]); } - snprintf (out_buf + len_used, out_len - 1 - len_used, ".%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf + len_used, out_len - len_used, ".%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", ptr[ 1], ptr[ 0], ptr[ 3], ptr[ 2], ptr[ 5], ptr[ 4], @@ -20622,10 +20622,10 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le for (i = 0, j = 0; i < rakp->salt_len; i += 1, j += 2) { - snprintf (out_buf + j, out_len - 1 - j, "%02x", ptr[i ^ 3]); // the ^ 3 index converts LE -> BE + snprintf (out_buf + j, out_len - j, "%02x", ptr[i ^ 3]); // the ^ 3 index converts LE -> BE } - snprintf (out_buf + j, out_len - 1 - j, ":%08x%08x%08x%08x%08x", + snprintf (out_buf + j, out_len - j, ":%08x%08x%08x%08x%08x", digest_buf[0], digest_buf[1], digest_buf[2], @@ -20649,11 +20649,11 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le if (salt.salt_iter == ROUNDS_SHA256CRYPT) { - snprintf (out_buf, out_len - 1, "$5$%s$%s", (char *) salt.salt_buf, ptr_plain); + snprintf (out_buf, out_len, "$5$%s$%s", (char *) salt.salt_buf, ptr_plain); } else { - snprintf (out_buf, out_len - 1, "$5$rounds=%u$%s$%s", salt.salt_iter, (char *) salt.salt_buf, ptr_plain); + snprintf (out_buf, out_len, "$5$rounds=%u$%s$%s", salt.salt_iter, (char *) salt.salt_buf, ptr_plain); } } else if (hash_mode == 7500) @@ -20681,7 +20681,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le *ptr_data = 0; - snprintf (out_buf, out_len - 1, "%s%s$%s$%s$%s", + snprintf (out_buf, out_len, "%s%s$%s$%s$%s", SIGNATURE_KRB5PA, (char *) krb5pa->user, (char *) krb5pa->realm, @@ -20690,14 +20690,14 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if ((hash_mode == 7700) || (hash_mode == 7701)) { - snprintf (out_buf, out_len - 1, "%s$%08X%08X", + snprintf (out_buf, out_len, "%s$%08X%08X", (char *) salt.salt_buf, digest_buf[0], digest_buf[1]); } else if ((hash_mode == 7800) || (hash_mode == 7801)) { - snprintf (out_buf, out_len - 1, "%s$%08X%08X%08X%08X%08X", + snprintf (out_buf, out_len, "%s$%08X%08X%08X%08X%08X", (char *) salt.salt_buf, digest_buf[0], digest_buf[1], @@ -20719,11 +20719,11 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le ptr_plain[43] = 0; - snprintf (out_buf, out_len - 1, "%s%s%s", (char *) salt.salt_sign, (char *) salt.salt_buf, ptr_plain); + snprintf (out_buf, out_len, "%s%s%s", (char *) salt.salt_sign, (char *) salt.salt_buf, ptr_plain); } else if (hash_mode == 8000) { - snprintf (out_buf, out_len - 1, "0xc007%s%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "0xc007%s%08x%08x%08x%08x%08x%08x%08x%08x", (unsigned char *) salt.salt_buf, digest_buf[0], digest_buf[1], @@ -20739,7 +20739,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le salt.salt_buf[0] = byte_swap_32 (salt.salt_buf[0]); salt.salt_buf[1] = byte_swap_32 (salt.salt_buf[1]); - snprintf (out_buf, out_len - 1, "1%s%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "1%s%08x%08x%08x%08x%08x", (unsigned char *) salt.salt_buf, digest_buf[0], digest_buf[1], @@ -20776,7 +20776,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le salt.salt_buf[2] = byte_swap_32 (salt.salt_buf[2]); salt.salt_buf[3] = byte_swap_32 (salt.salt_buf[3]); - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x%08x:%08x%08x%08x%08x:%u:%s", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x%08x:%08x%08x%08x%08x:%u:%s", digest_buf[0], digest_buf[1], digest_buf[2], @@ -20827,15 +20827,15 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le // final - snprintf (out_buf, out_len - 1, "%s:%s:%s:%u", digest_buf_c, domain_buf_c, (char *) salt.salt_buf, salt.salt_iter); + snprintf (out_buf, out_len, "%s:%s:%s:%u", digest_buf_c, domain_buf_c, (char *) salt.salt_buf, salt.salt_iter); } else if (hash_mode == 8500) { - snprintf (out_buf, out_len - 1, "%s*%s*%08X%08X", SIGNATURE_RACF, (char *) salt.salt_buf, digest_buf[0], digest_buf[1]); + snprintf (out_buf, out_len, "%s*%s*%08X%08X", SIGNATURE_RACF, (char *) salt.salt_buf, digest_buf[0], digest_buf[1]); } else if (hash_mode == 2612) { - snprintf (out_buf, out_len - 1, "%s%s$%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%s$%08x%08x%08x%08x", SIGNATURE_PHPS, (char *) salt.salt_buf, digest_buf[0], @@ -20849,7 +20849,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le salt_ptr[salt.salt_len - 1] = 0; - snprintf (out_buf, out_len - 1, "%s%s$%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%s$%08x%08x%08x%08x", SIGNATURE_MEDIAWIKI_B, salt_ptr, digest_buf[0], @@ -20872,7 +20872,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le tmp[3072] = 0; - snprintf (out_buf, out_len - 1, "%s16$%08x%08x%08x%08x$16$%08x%08x%08x%08x$%s", + snprintf (out_buf, out_len, "%s16$%08x%08x%08x%08x$16$%08x%08x%08x%08x$%s", SIGNATURE_ANDROIDFDE, byte_swap_32 (salt.salt_buf[0]), byte_swap_32 (salt.salt_buf[1]), @@ -20908,7 +20908,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le base64_encode (int_to_base64, (const u8 *) digest_buf, 32, (u8 *) tmp_buf); - snprintf (out_buf, out_len - 1, "%s:%u:%u:%u:%s:%s", + snprintf (out_buf, out_len, "%s:%u:%u:%u:%s:%s", SIGNATURE_SCRYPT, N, r, @@ -20918,7 +20918,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 9000) { - snprintf (out_buf, out_len - 1, "%s", hashfile); + snprintf (out_buf, out_len, "%s", hashfile); } else if (hash_mode == 9200) { @@ -20948,7 +20948,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le // output - snprintf (out_buf, out_len - 1, "%s%s$%s", SIGNATURE_CISCO8, salt_buf_ptr, tmp_buf); + snprintf (out_buf, out_len, "%s%s$%s", SIGNATURE_CISCO8, salt_buf_ptr, tmp_buf); } else if (hash_mode == 9300) { @@ -20968,7 +20968,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le unsigned char *salt_buf_ptr = (unsigned char *) salt.salt_buf; - snprintf (out_buf, out_len - 1, "%s%s$%s", SIGNATURE_CISCO9, salt_buf_ptr, tmp_buf); + snprintf (out_buf, out_len, "%s%s$%s", SIGNATURE_CISCO9, salt_buf_ptr, tmp_buf); } else if (hash_mode == 9400) { @@ -20976,7 +20976,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le office2007_t *office2007 = &office2007s[digest_cur]; - snprintf (out_buf, out_len - 1, "%s*%d*%d*%u*%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s*%d*%d*%u*%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x", SIGNATURE_OFFICE2007, 2007, 20, @@ -21002,7 +21002,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le office2010_t *office2010 = &office2010s[digest_cur]; - snprintf (out_buf, out_len - 1, "%s*%d*%d*%d*%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s*%d*%d*%d*%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x%08x%08x%08x", SIGNATURE_OFFICE2010, 2010, 100000, @@ -21031,7 +21031,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le office2013_t *office2013 = &office2013s[digest_cur]; - snprintf (out_buf, out_len - 1, "%s*%d*%d*%d*%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s*%d*%d*%d*%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x%08x%08x%08x", SIGNATURE_OFFICE2013, 2013, 100000, @@ -21060,7 +21060,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le oldoffice01_t *oldoffice01 = &oldoffice01s[digest_cur]; - snprintf (out_buf, out_len - 1, "%s%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x", SIGNATURE_OLDOFFICE, oldoffice01->version, byte_swap_32 (salt.salt_buf[0]), @@ -21082,7 +21082,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le oldoffice01_t *oldoffice01 = &oldoffice01s[digest_cur]; - snprintf (out_buf, out_len - 1, "%s%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x", SIGNATURE_OLDOFFICE, oldoffice01->version, byte_swap_32 (salt.salt_buf[0]), @@ -21106,7 +21106,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le u8 *rc4key = (u8 *) oldoffice01->rc4key; - snprintf (out_buf, out_len - 1, "%s%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x:%02x%02x%02x%02x%02x", + snprintf (out_buf, out_len, "%s%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x:%02x%02x%02x%02x%02x", SIGNATURE_OLDOFFICE, oldoffice01->version, byte_swap_32 (salt.salt_buf[0]), @@ -21133,7 +21133,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le oldoffice34_t *oldoffice34 = &oldoffice34s[digest_cur]; - snprintf (out_buf, out_len - 1, "%s%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x", SIGNATURE_OLDOFFICE, oldoffice34->version, salt.salt_buf[0], @@ -21156,7 +21156,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le oldoffice34_t *oldoffice34 = &oldoffice34s[digest_cur]; - snprintf (out_buf, out_len - 1, "%s%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x", SIGNATURE_OLDOFFICE, oldoffice34->version, salt.salt_buf[0], @@ -21181,7 +21181,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le u8 *rc4key = (u8 *) oldoffice34->rc4key; - snprintf (out_buf, out_len - 1, "%s%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x:%02x%02x%02x%02x%02x", + snprintf (out_buf, out_len, "%s%d*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x:%02x%02x%02x%02x%02x", SIGNATURE_OLDOFFICE, oldoffice34->version, salt.salt_buf[0], @@ -21229,11 +21229,11 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le // output - snprintf (out_buf, out_len - 1, "%s$%u$%s$%s", SIGNATURE_DJANGOPBKDF2, salt.salt_iter + 1, salt_buf_ptr, tmp_buf); + snprintf (out_buf, out_len, "%s$%u$%s$%s", SIGNATURE_DJANGOPBKDF2, salt.salt_iter + 1, salt_buf_ptr, tmp_buf); } else if (hash_mode == 10100) { - snprintf (out_buf, out_len - 1, "%08x%08x:%d:%d:%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x:%d:%d:%08x%08x%08x%08x", digest_buf[0], digest_buf[1], 2, @@ -21257,7 +21257,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le // response - int tmp_len = snprintf (tmp_buf, sizeof (tmp_buf) - 1, "%s %08x%08x%08x%08x", + int tmp_len = snprintf (tmp_buf, sizeof (tmp_buf), "%s %08x%08x%08x%08x", (char *) cram_md5->user, digest_buf[0], digest_buf[1], @@ -21268,7 +21268,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le base64_encode (int_to_base64, (const u8 *) tmp_buf, tmp_len, (u8 *) response); - snprintf (out_buf, out_len - 1, "%s%s$%s", SIGNATURE_CRAM_MD5, challenge, response); + snprintf (out_buf, out_len, "%s%s$%s", SIGNATURE_CRAM_MD5, challenge, response); } else if (hash_mode == 10300) { @@ -21283,7 +21283,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le base64_encode (int_to_base64, (const u8 *) tmp_buf, tmp_len, (u8 *) base64_encoded); - snprintf (out_buf, out_len - 1, "%s%u}%s", SIGNATURE_SAPH_SHA1, salt.salt_iter + 1, base64_encoded); + snprintf (out_buf, out_len, "%s%u}%s", SIGNATURE_SAPH_SHA1, salt.salt_iter + 1, base64_encoded); } else if (hash_mode == 10400) { @@ -21291,7 +21291,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le pdf_t *pdf = &pdfs[digest_cur]; - snprintf (out_buf, out_len - 1, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", pdf->V, pdf->R, @@ -21329,7 +21329,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le pdf_t *pdf = &pdfs[digest_cur]; - snprintf (out_buf, out_len - 1, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", pdf->V, pdf->R, @@ -21369,7 +21369,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le u8 *rc4key = (u8 *) pdf->rc4key; - snprintf (out_buf, out_len - 1, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x:%02x%02x%02x%02x%02x", + snprintf (out_buf, out_len, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x:%02x%02x%02x%02x%02x", pdf->V, pdf->R, @@ -21414,7 +21414,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le if (pdf->id_len == 32) { - snprintf (out_buf, out_len - 1, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", pdf->V, pdf->R, @@ -21452,7 +21452,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else { - snprintf (out_buf, out_len - 1, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", pdf->V, pdf->R, @@ -21490,21 +21490,21 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le hashinfo_t **hashinfo_ptr = hash_info; char *hash_buf = hashinfo_ptr[digest_cur]->orighash; - snprintf (out_buf, out_len - 1, "%s", hash_buf); + snprintf (out_buf, out_len, "%s", hash_buf); } else if (hash_mode == 10700) { hashinfo_t **hashinfo_ptr = hash_info; char *hash_buf = hashinfo_ptr[digest_cur]->orighash; - snprintf (out_buf, out_len - 1, "%s", hash_buf); + snprintf (out_buf, out_len, "%s", hash_buf); } else if (hash_mode == 10900) { hashinfo_t **hashinfo_ptr = hash_info; char *hash_buf = hashinfo_ptr[digest_cur]->orighash; - snprintf (out_buf, out_len - 1, "%s", hash_buf); + snprintf (out_buf, out_len, "%s", hash_buf); } else if (hash_mode == 11100) { @@ -21514,7 +21514,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le unsigned char *user_name = (unsigned char *) (salt.salt_buf + 1); - snprintf (out_buf, out_len - 1, "%s%s*%08x*%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%s*%08x*%08x%08x%08x%08x", SIGNATURE_POSTGRESQL_AUTH, user_name, salt_challenge, @@ -21525,7 +21525,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 11200) { - snprintf (out_buf, out_len - 1, "%s%s*%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%s*%08x%08x%08x%08x%08x", SIGNATURE_MYSQL_AUTH, (unsigned char *) salt.salt_buf, digest_buf[0], @@ -21569,7 +21569,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le sprintf (public_key_buf + j, "%02x", ptr[i]); } - snprintf (out_buf, out_len - 1, "%s%u$%s$%u$%s$%u$%u$%s$%u$%s", + snprintf (out_buf, out_len, "%s%u$%s$%u$%s$%u$%u$%s$%u$%s", SIGNATURE_BITCOIN_WALLET, cry_master_len * 2, cry_master_buf, @@ -21591,11 +21591,11 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le hashinfo_t **hashinfo_ptr = hash_info; char *hash_buf = hashinfo_ptr[digest_cur]->orighash; - snprintf (out_buf, out_len - 1, "%s", hash_buf); + snprintf (out_buf, out_len, "%s", hash_buf); } else if (hash_mode == 11500) { - snprintf (out_buf, out_len - 1, "%08x:%s", byte_swap_32 (digest_buf[0]), (char *) salt.salt_buf); + snprintf (out_buf, out_len, "%08x:%s", byte_swap_32 (digest_buf[0]), (char *) salt.salt_buf); } else if (hash_mode == 11600) { @@ -21632,7 +21632,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le cost++; } - snprintf (out_buf, out_len - 1, "%s%u$%u$%u$%s$%u$%08x%08x%08x%08x$%u$%u$%u$%s", + snprintf (out_buf, out_len, "%s%u$%u$%u$%s$%u$%08x%08x%08x%08x$%u$%u$%u$%s", SIGNATURE_SEVEN_ZIP, salt.salt_sign[0], cost, @@ -21652,7 +21652,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le { u32 bytes_written = strlen (out_buf); - snprintf (out_buf + bytes_written, out_len - bytes_written - 1, "$%u$", seven_zip->crc_len); + snprintf (out_buf + bytes_written, out_len - bytes_written, "$%u$", seven_zip->crc_len); bytes_written = strlen (out_buf); @@ -21660,7 +21660,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le for (u32 i = 0, j = 0; i < seven_zip->coder_attributes_len; i += 1, j += 2) { - snprintf (out_buf + bytes_written, out_len - bytes_written - 1, "%02x", ptr[i]); + snprintf (out_buf + bytes_written, out_len - bytes_written, "%02x", ptr[i]); bytes_written += 2; } @@ -21670,7 +21670,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 11700 || hash_mode == 11750 || hash_mode == 11760) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x%08x", digest_buf[0], digest_buf[1], digest_buf[2], @@ -21682,7 +21682,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 11800 || hash_mode == 11850 || hash_mode == 11860) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", byte_swap_32 (digest_buf[ 0]), byte_swap_32 (digest_buf[ 1]), byte_swap_32 (digest_buf[ 2]), @@ -21705,34 +21705,34 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le hashinfo_t **hashinfo_ptr = hash_info; char *hash_buf = hashinfo_ptr[digest_cur]->orighash; - snprintf (out_buf, out_len - 1, "%s", hash_buf); + snprintf (out_buf, out_len, "%s", hash_buf); } else if (hash_mode == 12000) { hashinfo_t **hashinfo_ptr = hash_info; char *hash_buf = hashinfo_ptr[digest_cur]->orighash; - snprintf (out_buf, out_len - 1, "%s", hash_buf); + snprintf (out_buf, out_len, "%s", hash_buf); } else if (hash_mode == 12001) { hashinfo_t **hashinfo_ptr = hash_info; char *hash_buf = hashinfo_ptr[digest_cur]->orighash; - snprintf (out_buf, out_len - 1, "%s", hash_buf); + snprintf (out_buf, out_len, "%s", hash_buf); } else if (hash_mode == 12100) { hashinfo_t **hashinfo_ptr = hash_info; char *hash_buf = hashinfo_ptr[digest_cur]->orighash; - snprintf (out_buf, out_len - 1, "%s", hash_buf); + snprintf (out_buf, out_len, "%s", hash_buf); } else if (hash_mode == 12200) { u32 *ptr_digest = digest_buf; - snprintf (out_buf, out_len - 1, "%s0$1$%08x%08x$%08x%08x", + snprintf (out_buf, out_len, "%s0$1$%08x%08x$%08x%08x", SIGNATURE_ECRYPTFS, salt.salt_buf[0], salt.salt_buf[1], @@ -21743,7 +21743,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le { u32 *ptr_digest = digest_buf; - snprintf (out_buf, out_len - 1, "%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X", + snprintf (out_buf, out_len, "%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], ptr_digest[ 2], ptr_digest[ 3], ptr_digest[ 4], ptr_digest[ 5], @@ -21792,11 +21792,11 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le // fill the resulting buffer - snprintf (out_buf, out_len - 1, "_%s%s%s", salt_iter, ptr_salt, ptr_plain); + snprintf (out_buf, out_len, "_%s%s%s", salt_iter, ptr_salt, ptr_plain); } else if (hash_mode == 12500) { - snprintf (out_buf, out_len - 1, "%s*0*%08x%08x*%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s*0*%08x%08x*%08x%08x%08x%08x", SIGNATURE_RAR3, byte_swap_32 (salt.salt_buf[0]), byte_swap_32 (salt.salt_buf[1]), @@ -21807,7 +21807,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 12600) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x%08x", digest_buf[0] + salt.salt_buf_pc[0], digest_buf[1] + salt.salt_buf_pc[1], digest_buf[2] + salt.salt_buf_pc[2], @@ -21822,13 +21822,13 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le hashinfo_t **hashinfo_ptr = hash_info; char *hash_buf = hashinfo_ptr[digest_cur]->orighash; - snprintf (out_buf, out_len - 1, "%s", hash_buf); + snprintf (out_buf, out_len, "%s", hash_buf); } else if (hash_mode == 12800) { const u8 *ptr = (const u8 *) salt.salt_buf; - snprintf (out_buf, out_len - 1, "%s,%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x,%u,%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s,%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x,%u,%08x%08x%08x%08x%08x%08x%08x%08x", SIGNATURE_MS_DRSR, ptr[0], ptr[1], @@ -21853,7 +21853,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 12900) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", salt.salt_buf[ 4], salt.salt_buf[ 5], salt.salt_buf[ 6], @@ -21882,7 +21882,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le rar5_t *rar5 = &rar5s[digest_cur]; - snprintf (out_buf, out_len - 1, "$rar5$16$%08x%08x%08x%08x$%u$%08x%08x%08x%08x$8$%08x%08x", + snprintf (out_buf, out_len, "$rar5$16$%08x%08x%08x%08x$%u$%08x%08x%08x%08x$8$%08x%08x", salt.salt_buf[0], salt.salt_buf[1], salt.salt_buf[2], @@ -21911,7 +21911,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le sprintf (data + j, "%02x", ptr_edata2[i]); } - snprintf (out_buf, out_len - 1, "%s%s%08x%08x%08x%08x$%s", + snprintf (out_buf, out_len, "%s%s%08x%08x%08x%08x$%s", SIGNATURE_KRB5TGS, (char *) krb5tgs->account_info, byte_swap_32 (krb5tgs->checksum[0]), @@ -21922,7 +21922,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 13200) { - snprintf (out_buf, out_len - 1, "%s*1*%u*%08x%08x%08x%08x*%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s*1*%u*%08x%08x%08x%08x*%08x%08x%08x%08x%08x%08x", SIGNATURE_AXCRYPT, salt.salt_iter, salt.salt_buf[0], @@ -21938,7 +21938,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 13300) { - snprintf (out_buf, out_len - 1, "%s%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%08x%08x%08x%08x", SIGNATURE_AXCRYPT_SHA1, digest_buf[0], digest_buf[1], @@ -21979,7 +21979,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le if (version == 1) final_random_seed_len = 4; - snprintf (out_buf, out_len - 1, "%s*%u*%u*%u", + snprintf (out_buf, out_len, "%s*%u*%u*%u", SIGNATURE_KEEPASS, version, rounds, @@ -22096,7 +22096,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le sprintf (pstoken_tmp + j, "%02x", ptr[i]); } - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x:%s", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x:%s", digest_buf[0], digest_buf[1], digest_buf[2], @@ -22143,7 +22143,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le sprintf (auth_tmp + j, "%02x", ptr[i]); } - snprintf (out_buf, out_len - 1, "%s*%u*%u*%u*%s*%x*%u*%s*%s*%s", + snprintf (out_buf, out_len, "%s*%u*%u*%u*%s*%x*%u*%s*%s*%s", SIGNATURE_ZIP2_START, zip2->type, zip2->mode, @@ -22157,7 +22157,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if ((hash_mode >= 13700) && (hash_mode <= 13799)) { - snprintf (out_buf, out_len - 1, "%s", hashfile); + snprintf (out_buf, out_len, "%s", hashfile); } else if (hash_mode == 13800) { @@ -22172,7 +22172,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le sprintf (buf + j, "%08x", esalt->salt_buf[i]); } - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x%08x:%s", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x%08x:%s", digest_buf[0], digest_buf[1], digest_buf[2], @@ -22185,15 +22185,15 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 14000) { - snprintf (out_buf, out_len - 1, "%08x%08x:%s", digest_buf[0], digest_buf[1], (char *) salt.salt_buf); + snprintf (out_buf, out_len, "%08x%08x:%s", digest_buf[0], digest_buf[1], (char *) salt.salt_buf); } else if (hash_mode == 14100) { - snprintf (out_buf, out_len - 1, "%08x%08x:%s", digest_buf[0], digest_buf[1], (char *) salt.salt_buf); + snprintf (out_buf, out_len, "%08x%08x:%s", digest_buf[0], digest_buf[1], (char *) salt.salt_buf); } else if (hash_mode == 14400) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x", byte_swap_32 (digest_buf[0]), byte_swap_32 (digest_buf[1]), byte_swap_32 (digest_buf[2]), @@ -22202,7 +22202,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 14600) { - snprintf (out_buf, out_len - 1, "%s", hashfile); + snprintf (out_buf, out_len, "%s", hashfile); } else if (hash_mode == 14700) { @@ -22239,7 +22239,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le wpky[80] = 0; - snprintf (out_buf, out_len - 1, "%s*%u*%s*%u*%s**", + snprintf (out_buf, out_len, "%s*%u*%s*%u*%s**", SIGNATURE_ITUNES_BACKUP, salt.salt_sign[0], wpky, @@ -22301,7 +22301,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le dpsl[40] = 0; - snprintf (out_buf, out_len - 1, "%s*%u*%s*%u*%s*%u*%s", + snprintf (out_buf, out_len, "%s*%u*%s*%u*%s*%u*%s", SIGNATURE_ITUNES_BACKUP, salt.salt_sign[0], wpky, @@ -22312,7 +22312,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_mode == 14900) { - snprintf (out_buf, out_len - 1, "%08x:%08x", digest_buf[0], salt.salt_buf[0]); + snprintf (out_buf, out_len, "%08x:%08x", digest_buf[0], salt.salt_buf[0]); } else if (hash_mode == 15100) { @@ -22322,7 +22322,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le // output: - snprintf (out_buf, out_len - 1, "$sha1$%u$%s$%s", + snprintf (out_buf, out_len, "$sha1$%u$%s$%s", salt.salt_iter + 1, (char *) salt.salt_buf, ptr_plain); @@ -22332,7 +22332,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le hashinfo_t **hashinfo_ptr = hash_info; char *hash_buf = hashinfo_ptr[digest_cur]->orighash; - snprintf (out_buf, out_len - 1, "%s", hash_buf); + snprintf (out_buf, out_len, "%s", hash_buf); } else if (hash_mode == 15300) { @@ -22407,7 +22407,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le memcpy(hash_algorithm, "sha1", strlen("sha1")); } - snprintf (out_buf, out_len - 1, "%s%u*%u*%s*%s*%s*%u*%s*%u*%s", + snprintf (out_buf, out_len, "%s%u*%u*%s*%s*%s*%u*%s*%u*%s", SIGNATURE_DPAPIMK, version, context, @@ -22436,7 +22436,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le u8 *der = (u8 *) jks_sha1->der; - snprintf (out_buf, out_len - 1, "%s*%08X%08X%08X%08X%08X*%08X%08X%08X%08X%08X*%s*%02X*%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X*%s", + snprintf (out_buf, out_len, "%s*%08X%08X%08X%08X%08X*%08X%08X%08X%08X%08X*%s*%02X*%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X*%s", SIGNATURE_JKS_SHA1, byte_swap_32 (jks_sha1->checksum[0]), byte_swap_32 (jks_sha1->checksum[1]), @@ -22472,7 +22472,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le ethereum_pbkdf2_t *ethereum_pbkdf2s = (ethereum_pbkdf2_t *) esalts_buf; ethereum_pbkdf2_t *ethereum_pbkdf2 = ðereum_pbkdf2s[digest_cur]; - snprintf (out_buf, out_len - 1, "%s*%u*%s*%08x%08x%08x%08x%08x%08x%08x%08x*%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s*%u*%s*%08x%08x%08x%08x%08x%08x%08x%08x*%08x%08x%08x%08x%08x%08x%08x%08x", SIGNATURE_ETHEREUM_PBKDF2, salt.salt_iter + 1, (char *) salt.salt_buf, @@ -22499,7 +22499,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le ethereum_scrypt_t *ethereum_scrypts = (ethereum_scrypt_t *) esalts_buf; ethereum_scrypt_t *ethereum_scrypt = ðereum_scrypts[digest_cur]; - snprintf (out_buf, out_len - 1, "%s*%u*%u*%u*%s*%08x%08x%08x%08x%08x%08x%08x%08x*%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s*%u*%u*%u*%s*%08x%08x%08x%08x%08x%08x%08x%08x*%08x%08x%08x%08x%08x%08x%08x%08x", SIGNATURE_ETHEREUM_SCRYPT, salt.scrypt_N, salt.scrypt_r, @@ -22596,7 +22596,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le memcpy(hash_algorithm, "sha512", strlen("sha512")); } - snprintf (out_buf, out_len - 1, "%s%d*%d*%s*%s*%s*%d*%s*%d*%s", + snprintf (out_buf, out_len, "%s%d*%d*%s*%s*%s*%d*%s*%d*%s", SIGNATURE_DPAPIMK, version, context, @@ -22621,7 +22621,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le base64_encode (int_to_itoa64, (const u8 *) tmp_buf, 8, (u8 *) ptr_plain); - snprintf (out_buf, out_len - 1, "%s", ptr_plain + 1); + snprintf (out_buf, out_len, "%s", ptr_plain + 1); out_buf[10] = 0; } @@ -22643,7 +22643,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le u8 *session_ptr = (u8 *) tacacs_plus->session_buf; u8 *sequence_ptr = (u8 *) tacacs_plus->sequence_buf; - snprintf (out_buf, out_len - 1, "%s%02x%02x%02x%02x$%s$%02x%02x", + snprintf (out_buf, out_len, "%s%02x%02x%02x%02x$%s$%02x%02x", SIGNATURE_TACACS_PLUS, session_ptr[0], session_ptr[1], @@ -22659,7 +22659,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le apple_secure_notes_t *apple_secure_notes = &apple_secure_notess[digest_cur]; - snprintf (out_buf, out_len - 1, "%s*%u*%u*%08x%08x%08x%08x*%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s*%u*%u*%08x%08x%08x%08x*%08x%08x%08x%08x%08x%08x", SIGNATURE_APPLE_SECURE_NOTES, apple_secure_notes->Z_PK, apple_secure_notes->ZCRYPTOITERATIONCOUNT, @@ -22716,7 +22716,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le // output: - snprintf (out_buf, out_len - 1, "%s*%s*%s*%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s*%s*%s*%08x%08x%08x%08x", SIGNATURE_ETHEREUM_PRESALE, encseed, (char *) salt.salt_buf, @@ -22731,7 +22731,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le hashinfo_t **hashinfo_ptr = hash_info; char *hash_buf = hashinfo_ptr[digest_cur]->orighash; - snprintf (out_buf, out_len - 1, "%s", hash_buf); + snprintf (out_buf, out_len, "%s", hash_buf); } else if (hash_mode == 16500) { @@ -22795,7 +22795,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le ptr_plain[86] = 0; } - snprintf (out_buf, out_len - 1, "%s.%s", + snprintf (out_buf, out_len, "%s.%s", (char *) jwt->salt_buf, (char *) ptr_plain); } @@ -22805,7 +22805,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le electrum_wallet_t *electrum_wallet = &electrum_wallets[digest_cur]; - snprintf (out_buf, out_len - 1, "%s%d*%08x%08x%08x%08x*%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%d*%08x%08x%08x%08x*%08x%08x%08x%08x", SIGNATURE_ELECTRUM_WALLET, electrum_wallet->salt_type, byte_swap_32 (electrum_wallet->iv[0]), @@ -22823,7 +22823,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le apple_secure_notes_t *apple_secure_notes = &apple_secure_notess[digest_cur]; - snprintf (out_buf, out_len - 1, "%s%u$16$%08x%08x%08x%08x$%u$%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%u$16$%08x%08x%08x%08x$%u$%08x%08x%08x%08x%08x%08x", SIGNATURE_FILEVAULT2, apple_secure_notes->Z_PK, byte_swap_32 (apple_secure_notes->ZCRYPTOSALT[0]), @@ -22850,7 +22850,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le tmp_buf[tmp_len] = 0; - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x*%02x%02x%02x%02x%02x%02x*%02x%02x%02x%02x%02x%02x*%s", + snprintf (out_buf, out_len, "%08x%08x%08x%08x*%02x%02x%02x%02x%02x%02x*%02x%02x%02x%02x%02x%02x*%s", byte_swap_32 (wpa_pmkid->pmkid[0]), byte_swap_32 (wpa_pmkid->pmkid[1]), byte_swap_32 (wpa_pmkid->pmkid[2]), @@ -22883,7 +22883,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le tmp_buf[tmp_len] = 0; - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x*%02x%02x%02x%02x%02x%02x*%02x%02x%02x%02x%02x%02x*%s", + snprintf (out_buf, out_len, "%08x%08x%08x%08x*%02x%02x%02x%02x%02x%02x*%02x%02x%02x%02x%02x%02x*%s", byte_swap_32 (wpa_pmkid->pmkid[0]), byte_swap_32 (wpa_pmkid->pmkid[1]), byte_swap_32 (wpa_pmkid->pmkid[2]), @@ -22904,7 +22904,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x*%02x%02x%02x%02x%02x%02x*%02x%02x%02x%02x%02x%02x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x*%02x%02x%02x%02x%02x%02x*%02x%02x%02x%02x%02x%02x", byte_swap_32 (wpa_pmkid->pmkid[0]), byte_swap_32 (wpa_pmkid->pmkid[1]), byte_swap_32 (wpa_pmkid->pmkid[2]), @@ -22938,7 +22938,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le u32_to_hex_lower (ct_data_ptr[i], ct_data + j); } - snprintf (out_buf, out_len - 1, "%s%u*%u*%08x%08x%08x%08x%08x%08x%08x%08x*%s*%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%u*%u*%08x%08x%08x%08x%08x%08x%08x%08x*%s*%08x%08x%08x%08x%08x%08x%08x%08x", SIGNATURE_ANSIBLE_VAULT, ansible_vault->cipher, ansible_vault->version, @@ -22964,7 +22964,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le { u32 *ptr = digest_buf; - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x", ptr[1], ptr[0], ptr[3], ptr[2], ptr[5], ptr[4], @@ -22975,7 +22975,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le { u32 *ptr = digest_buf; - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x%08x", ptr[1], ptr[0], ptr[3], ptr[2], ptr[5], ptr[4], @@ -22986,7 +22986,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le { u32 *ptr = digest_buf; - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", ptr[ 1], ptr[ 0], ptr[ 3], ptr[ 2], ptr[ 5], ptr[ 4], @@ -22999,7 +22999,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le { u32 *ptr = digest_buf; - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", ptr[ 1], ptr[ 0], ptr[ 3], ptr[ 2], ptr[ 5], ptr[ 4], @@ -23018,7 +23018,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le u64 tmp_salt_buf = (((u64) (salt.salt_buf[2])) << 32) | ((u64) (salt.salt_buf[3])); - snprintf (out_buf, out_len - 1, "%06d:%" PRIu64, digest_buf[0], tmp_salt_buf); + snprintf (out_buf, out_len, "%06d:%" PRIu64, digest_buf[0], tmp_salt_buf); } else if (hash_mode == 18200) { @@ -23035,7 +23035,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le sprintf (data + j, "%02x", ptr_edata2[i]); } - snprintf (out_buf, out_len - 1, "%s%s%08x%08x%08x%08x$%s", + snprintf (out_buf, out_len, "%s%s%08x%08x%08x%08x$%s", SIGNATURE_KRB5ASREP, (char *) krb5asrep->account_info, byte_swap_32 (krb5asrep->checksum[0]), @@ -23050,7 +23050,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le apple_secure_notes_t *apple_secure_notes = &apple_secure_notess[digest_cur]; - snprintf (out_buf, out_len - 1, "%s%u$16$%08x%08x%08x%08x$%u$%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%u$16$%08x%08x%08x%08x$%u$%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", SIGNATURE_FILEVAULT2, apple_secure_notes->Z_PK, byte_swap_32 (apple_secure_notes->ZCRYPTOSALT[0]), @@ -23077,7 +23077,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le size_t pos = 0; - snprintf (out_buf, out_len - 1, "%s*1*1*%d*32*%08x%08x%08x%08x%08x%08x%08x%08x*16*%08x%08x%08x%08x*16*%08x%08x%08x%08x*0*", + snprintf (out_buf, out_len, "%s*1*1*%d*32*%08x%08x%08x%08x%08x%08x%08x%08x*16*%08x%08x%08x%08x*16*%08x%08x%08x%08x*0*", SIGNATURE_ODF, odf12->iterations, byte_swap_32 (odf12->checksum[0]), @@ -23101,7 +23101,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le for (int i = 0; i < 256; i += 8, pos += 64) { - snprintf (&out_buf[pos], out_len - pos - 1, "%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (&out_buf[pos], out_len - pos, "%08x%08x%08x%08x%08x%08x%08x%08x", byte_swap_32 (odf12->encrypted_data[i + 0]), byte_swap_32 (odf12->encrypted_data[i + 1]), byte_swap_32 (odf12->encrypted_data[i + 2]), @@ -23116,13 +23116,13 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le { char *ptr = (char *) digest_buf; - snprintf (out_buf, out_len - 1, "%s", ptr + 64); + snprintf (out_buf, out_len, "%s", ptr + 64); } else { if (hash_type == HASH_TYPE_MD4) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x", digest_buf[0], digest_buf[1], digest_buf[2], @@ -23130,7 +23130,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_type == HASH_TYPE_MD5) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x", digest_buf[0], digest_buf[1], digest_buf[2], @@ -23138,7 +23138,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_type == HASH_TYPE_SHA1) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x", digest_buf[0], digest_buf[1], digest_buf[2], @@ -23147,7 +23147,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_type == HASH_TYPE_SHA224) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x", digest_buf[0], digest_buf[1], digest_buf[2], @@ -23158,7 +23158,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_type == HASH_TYPE_SHA256) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x%08x", digest_buf[0], digest_buf[1], digest_buf[2], @@ -23172,7 +23172,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le { u32 *ptr = digest_buf; - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", ptr[ 1], ptr[ 0], ptr[ 3], ptr[ 2], ptr[ 5], ptr[ 4], @@ -23184,7 +23184,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le { u32 *ptr = digest_buf; - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", ptr[ 1], ptr[ 0], ptr[ 3], ptr[ 2], ptr[ 5], ptr[ 4], @@ -23196,13 +23196,13 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_type == HASH_TYPE_LM) { - snprintf (out_buf, out_len - 1, "%08x%08x", + snprintf (out_buf, out_len, "%08x%08x", digest_buf[0], digest_buf[1]); } else if (hash_type == HASH_TYPE_ORACLEH) { - snprintf (out_buf, out_len - 1, "%08X%08X", + snprintf (out_buf, out_len, "%08X%08X", digest_buf[0], digest_buf[1]); } @@ -23213,13 +23213,13 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le tmp_buf[22 + 31] = 0; // base64_encode wants to pad - snprintf (out_buf, out_len - 1, "%s$%s", (char *) salt.salt_sign, tmp_buf); + snprintf (out_buf, out_len, "%s$%s", (char *) salt.salt_sign, tmp_buf); } else if (hash_type == HASH_TYPE_BLAKE2B) { u32 *ptr = digest_buf; - snprintf (out_buf, out_len - 1, "%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", SIGNATURE_BLAKE2B, byte_swap_32 (ptr[ 0]), byte_swap_32 (ptr[ 1]), @@ -23245,7 +23245,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le const chacha20_t *chacha20_tmp = (const chacha20_t *) esalts_buf; const chacha20_t *chacha20 = &chacha20_tmp[digest_cur]; - snprintf (out_buf, out_len - 1, "%s*%08x%08x*%u*%08x%08x*%08x%08x*%08x%08x", + snprintf (out_buf, out_len, "%s*%08x%08x*%u*%08x%08x*%08x%08x*%08x%08x", SIGNATURE_CHACHA20, byte_swap_32 (chacha20->position[0]), byte_swap_32 (chacha20->position[1]), @@ -23259,7 +23259,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_type == HASH_TYPE_RIPEMD160) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x", digest_buf[0], digest_buf[1], digest_buf[2], @@ -23268,7 +23268,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_type == HASH_TYPE_WHIRLPOOL) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x", digest_buf[ 0], digest_buf[ 1], digest_buf[ 2], @@ -23288,7 +23288,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_type == HASH_TYPE_GOST) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x%08x%08x%08x%08x", digest_buf[0], digest_buf[1], digest_buf[2], @@ -23300,13 +23300,13 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le } else if (hash_type == HASH_TYPE_MYSQL) { - snprintf (out_buf, out_len - 1, "%08x%08x", + snprintf (out_buf, out_len, "%08x%08x", digest_buf[0], digest_buf[1]); } else if (hash_type == HASH_TYPE_LOTUS5) { - snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x", + snprintf (out_buf, out_len, "%08x%08x%08x%08x", digest_buf[0], digest_buf[1], digest_buf[2], @@ -23331,7 +23331,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le tmp_buf[18] = salt.salt_buf_pc[7]; tmp_buf[19] = 0; - snprintf (out_buf, out_len - 1, "(G%s)", tmp_buf); + snprintf (out_buf, out_len, "(G%s)", tmp_buf); } else if (hash_type == HASH_TYPE_LOTUS8) { @@ -23360,7 +23360,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le tmp_buf[49] = 0; - snprintf (out_buf, out_len - 1, "(H%s)", tmp_buf); + snprintf (out_buf, out_len, "(H%s)", tmp_buf); } } diff --git a/src/opencl.c b/src/opencl.c index 900fa900c..ecb824d20 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -4889,9 +4889,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) char build_opts_base[1024] = { 0 }; #if defined (_WIN) - snprintf (build_opts_base, sizeof (build_opts_base) - 1, "-cl-std=CL1.2 -I OpenCL -I \"%s\"", folder_config->cpath_real); + snprintf (build_opts_base, sizeof (build_opts_base), "-cl-std=CL1.2 -I OpenCL -I \"%s\"", folder_config->cpath_real); #else - snprintf (build_opts_base, sizeof (build_opts_base) - 1, "-cl-std=CL1.2 -I OpenCL -I %s", folder_config->cpath_real); + snprintf (build_opts_base, sizeof (build_opts_base), "-cl-std=CL1.2 -I OpenCL -I %s", folder_config->cpath_real); #endif // we don't have sm_* on vendors not NV but it doesn't matter @@ -4899,9 +4899,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) char build_opts[2048] = { 0 }; #if defined (DEBUG) - snprintf (build_opts, sizeof (build_opts) - 1, "%s -D LOCAL_MEM_TYPE=%u -D VENDOR_ID=%u -D CUDA_ARCH=%u -D AMD_ROCM=%u -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", build_opts_base, device_param->device_local_mem_type, device_param->platform_vendor_id, (device_param->sm_major * 100) + device_param->sm_minor, device_param->is_rocm, 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); + snprintf (build_opts, sizeof (build_opts), "%s -D LOCAL_MEM_TYPE=%u -D VENDOR_ID=%u -D CUDA_ARCH=%u -D AMD_ROCM=%u -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", build_opts_base, device_param->device_local_mem_type, device_param->platform_vendor_id, (device_param->sm_major * 100) + device_param->sm_minor, device_param->is_rocm, 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); #else - snprintf (build_opts, sizeof (build_opts) - 1, "%s -D LOCAL_MEM_TYPE=%u -D VENDOR_ID=%u -D CUDA_ARCH=%u -D AMD_ROCM=%u -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 -w", build_opts_base, device_param->device_local_mem_type, device_param->platform_vendor_id, (device_param->sm_major * 100) + device_param->sm_minor, device_param->is_rocm, 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); + snprintf (build_opts, sizeof (build_opts), "%s -D LOCAL_MEM_TYPE=%u -D VENDOR_ID=%u -D CUDA_ARCH=%u -D AMD_ROCM=%u -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 -w", build_opts_base, device_param->device_local_mem_type, device_param->platform_vendor_id, (device_param->sm_major * 100) + device_param->sm_minor, device_param->is_rocm, 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 /* @@ -4926,11 +4926,11 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) char *device_name_chksum_amp_mp = (char *) hcmalloc (HCBUFSIZ_TINY); #if defined (__x86_64__) - const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%d-%u-%u-%s-%s-%s-%d-%u-%u", 64, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime, user_options->opencl_vector_width, user_options->hash_mode); - const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY - 1, "%d-%u-%s-%s-%s-%d", 64, device_param->platform_vendor_id, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime); + const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY, "%d-%u-%u-%s-%s-%s-%d-%u-%u", 64, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime, user_options->opencl_vector_width, user_options->hash_mode); + const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY, "%d-%u-%s-%s-%s-%d", 64, device_param->platform_vendor_id, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime); #else - const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%d-%u-%u-%s-%s-%s-%d-%u-%u", 32, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime, user_options->opencl_vector_width, user_options->hash_mode); - const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY - 1, "%d-%u-%s-%s-%s-%d", 32, device_param->platform_vendor_id, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime); + const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY, "%d-%u-%u-%s-%s-%s-%d-%u-%u", 32, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime, user_options->opencl_vector_width, user_options->hash_mode); + const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY, "%d-%u-%s-%s-%s-%d", 32, device_param->platform_vendor_id, device_param->device_name, device_param->device_version, device_param->driver_version, opencl_ctx->comptime); #endif u32 device_name_digest[4] = { 0 }; @@ -4940,7 +4940,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) md5_64 ((u32 *) (device_name_chksum + i), device_name_digest); } - snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%08x", device_name_digest[0]); + snprintf (device_name_chksum, HCBUFSIZ_TINY, "%08x", device_name_digest[0]); u32 device_name_digest_amp_mp[4] = { 0 }; @@ -4949,7 +4949,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) md5_64 ((u32 *) (device_name_chksum_amp_mp + i), device_name_digest_amp_mp); } - snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY - 1, "%08x", device_name_digest_amp_mp[0]); + snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY, "%08x", device_name_digest_amp_mp[0]); /** * main kernel @@ -5734,7 +5734,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { // kernel1 - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_s%02d", hashconfig->kern_type, 4); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_s%02d", hashconfig->kern_type, 4); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); @@ -5754,7 +5754,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) // kernel2 - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_s%02d", hashconfig->kern_type, 8); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_s%02d", hashconfig->kern_type, 8); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); @@ -5774,7 +5774,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) // kernel3 - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_s%02d", hashconfig->kern_type, 16); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_s%02d", hashconfig->kern_type, 16); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); @@ -5794,7 +5794,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) } else { - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_sxx", hashconfig->kern_type); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_sxx", hashconfig->kern_type); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel4); @@ -5819,7 +5819,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { // kernel1 - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_m%02d", hashconfig->kern_type, 4); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_m%02d", hashconfig->kern_type, 4); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); @@ -5839,7 +5839,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) // kernel2 - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_m%02d", hashconfig->kern_type, 8); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_m%02d", hashconfig->kern_type, 8); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); @@ -5859,7 +5859,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) // kernel3 - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_m%02d", hashconfig->kern_type, 16); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_m%02d", hashconfig->kern_type, 16); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); @@ -5879,7 +5879,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) } else { - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_mxx", hashconfig->kern_type); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_mxx", hashconfig->kern_type); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel4); @@ -5908,7 +5908,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) { - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_tm", hashconfig->kern_type); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_tm", hashconfig->kern_type); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_tm); @@ -5933,7 +5933,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { // kernel1 - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_init", hashconfig->kern_type); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_init", hashconfig->kern_type); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); @@ -5953,7 +5953,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) // kernel2 - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_loop", hashconfig->kern_type); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_loop", hashconfig->kern_type); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); @@ -5973,7 +5973,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) // kernel3 - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_comp", hashconfig->kern_type); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_comp", hashconfig->kern_type); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); @@ -5995,7 +5995,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_HOOK12) { - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_hook12", hashconfig->kern_type); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_hook12", hashconfig->kern_type); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel12); @@ -6018,7 +6018,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_HOOK23) { - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_hook23", hashconfig->kern_type); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_hook23", hashconfig->kern_type); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel23); @@ -6041,7 +6041,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_INIT2) { - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_init2", hashconfig->kern_type); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_init2", hashconfig->kern_type); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_init2); @@ -6064,7 +6064,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_LOOP2) { - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_loop2", hashconfig->kern_type); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_loop2", hashconfig->kern_type); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_loop2); @@ -6087,7 +6087,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_AUX1) { - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_aux1", hashconfig->kern_type); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_aux1", hashconfig->kern_type); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux1); @@ -6110,7 +6110,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_AUX2) { - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_aux2", hashconfig->kern_type); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_aux2", hashconfig->kern_type); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux2); @@ -6133,7 +6133,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_AUX3) { - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_aux3", hashconfig->kern_type); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_aux3", hashconfig->kern_type); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux3); @@ -6156,7 +6156,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_AUX4) { - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_aux4", hashconfig->kern_type); + snprintf (kernel_name, sizeof (kernel_name), "m%05u_aux4", hashconfig->kern_type); CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux4); diff --git a/src/status.c b/src/status.c index b05f07cd4..e088df0a8 100644 --- a/src/status.c +++ b/src/status.c @@ -55,10 +55,10 @@ static char *status_get_rules_file (const hashcat_ctx_t *hashcat_ctx) for (i = 0; i < user_options->rp_files_cnt - 1; i++) { - tmp_len += snprintf (tmp_buf + tmp_len, HCBUFSIZ_TINY - tmp_len - 1, "%s, ", user_options->rp_files[i]); + tmp_len += snprintf (tmp_buf + tmp_len, HCBUFSIZ_TINY - tmp_len, "%s, ", user_options->rp_files[i]); } - tmp_len += snprintf (tmp_buf + tmp_len, HCBUFSIZ_TINY - tmp_len - 1, "%s", user_options->rp_files[i]); + tmp_len += snprintf (tmp_buf + tmp_len, HCBUFSIZ_TINY - tmp_len, "%s", user_options->rp_files[i]); tmp_buf[tmp_len] = 0; @@ -78,34 +78,34 @@ void format_timer_display (struct tm *tm, char *buf, size_t len) const char *time_entity1 = ((tm->tm_year - 70) == 1) ? time_entities_s[0] : time_entities_m[0]; const char *time_entity2 = ( tm->tm_yday == 1) ? time_entities_s[1] : time_entities_m[1]; - snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_year - 70, time_entity1, tm->tm_yday, time_entity2); + snprintf (buf, len, "%d %s, %d %s", tm->tm_year - 70, time_entity1, tm->tm_yday, time_entity2); } else if (tm->tm_yday) { const char *time_entity1 = (tm->tm_yday == 1) ? time_entities_s[1] : time_entities_m[1]; const char *time_entity2 = (tm->tm_hour == 1) ? time_entities_s[2] : time_entities_m[2]; - snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_yday, time_entity1, tm->tm_hour, time_entity2); + snprintf (buf, len, "%d %s, %d %s", tm->tm_yday, time_entity1, tm->tm_hour, time_entity2); } else if (tm->tm_hour) { const char *time_entity1 = (tm->tm_hour == 1) ? time_entities_s[2] : time_entities_m[2]; const char *time_entity2 = (tm->tm_min == 1) ? time_entities_s[3] : time_entities_m[3]; - snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_hour, time_entity1, tm->tm_min, time_entity2); + snprintf (buf, len, "%d %s, %d %s", tm->tm_hour, time_entity1, tm->tm_min, time_entity2); } else if (tm->tm_min) { const char *time_entity1 = (tm->tm_min == 1) ? time_entities_s[3] : time_entities_m[3]; const char *time_entity2 = (tm->tm_sec == 1) ? time_entities_s[4] : time_entities_m[4]; - snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_min, time_entity1, tm->tm_sec, time_entity2); + snprintf (buf, len, "%d %s, %d %s", tm->tm_min, time_entity1, tm->tm_sec, time_entity2); } else { const char *time_entity1 = (tm->tm_sec == 1) ? time_entities_s[4] : time_entities_m[4]; - snprintf (buf, len - 1, "%d %s", tm->tm_sec, time_entity1); + snprintf (buf, len, "%d %s", tm->tm_sec, time_entity1); } } @@ -133,11 +133,11 @@ void format_speed_display (double val, char *buf, size_t len) if (level == 0) { - snprintf (buf, len - 1, "%.0f ", val); + snprintf (buf, len, "%.0f ", val); } else { - snprintf (buf, len - 1, "%.1f %c", val, UNITS[level]); + snprintf (buf, len, "%.1f %c", val, UNITS[level]); } } @@ -165,11 +165,11 @@ void format_speed_display_1k (double val, char *buf, size_t len) if (level == 0) { - snprintf (buf, len - 1, "%.0f ", val); + snprintf (buf, len, "%.0f ", val); } else { - snprintf (buf, len - 1, "%.1f %c", val, UNITS[level]); + snprintf (buf, len, "%.1f %c", val, UNITS[level]); } } @@ -873,11 +873,11 @@ char *status_get_guess_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const i if (user_options_extra->attack_kern == ATTACK_KERN_BF) { - snprintf (display, HCBUFSIZ_TINY - 1, "[Generating]"); + snprintf (display, HCBUFSIZ_TINY, "[Generating]"); } else { - snprintf (display, HCBUFSIZ_TINY - 1, "[Copying]"); + snprintf (display, HCBUFSIZ_TINY, "[Copying]"); } if (device_param->skipped == true) return display; @@ -918,14 +918,14 @@ char *status_get_guess_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const i plain_ptr1[plain_len1 * 2] = 0; plain_ptr2[plain_len2 * 2] = 0; - snprintf (display, HCBUFSIZ_TINY - 1, "$HEX[%s] -> $HEX[%s]", plain_ptr1, plain_ptr2); + snprintf (display, HCBUFSIZ_TINY, "$HEX[%s] -> $HEX[%s]", plain_ptr1, plain_ptr2); } else { plain_ptr1[plain_len1] = 0; plain_ptr2[plain_len2] = 0; - snprintf (display, HCBUFSIZ_TINY - 1, "%s -> %s", plain_ptr1, plain_ptr2); + snprintf (display, HCBUFSIZ_TINY, "%s -> %s", plain_ptr1, plain_ptr2); } return display; @@ -1160,13 +1160,13 @@ 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, display_left); + snprintf (display, HCBUFSIZ_TINY, "%s; Runtime limited: %s", tmp_display, display_left); free (display_left); } else { - snprintf (display, HCBUFSIZ_TINY - 1, "%s; Runtime limit exceeded", tmp_display); + snprintf (display, HCBUFSIZ_TINY, "%s; Runtime limit exceeded", tmp_display); } free (tmp_display); @@ -1895,7 +1895,7 @@ char *status_get_brain_link_recv_bytes_sec_dev (const hashcat_ctx_t *hashcat_ctx char *display = (char *) hcmalloc (HCBUFSIZ_TINY); - snprintf (display, HCBUFSIZ_TINY - 1, "%.2f M", (double) (brain_link_recv_bytes * 8) / 1024 / 1024); + snprintf (display, HCBUFSIZ_TINY, "%.2f M", (double) (brain_link_recv_bytes * 8) / 1024 / 1024); return display; } @@ -1922,7 +1922,7 @@ char *status_get_brain_link_send_bytes_sec_dev (const hashcat_ctx_t *hashcat_ctx char *display = (char *) hcmalloc (HCBUFSIZ_TINY); - snprintf (display, HCBUFSIZ_TINY - 1, "%.2f M", (double) (brain_link_send_bytes * 8) / 1024 / 1024); + snprintf (display, HCBUFSIZ_TINY, "%.2f M", (double) (brain_link_send_bytes * 8) / 1024 / 1024); return display; } @@ -1936,7 +1936,7 @@ char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int device_i char *output_buf = (char *) hcmalloc (HCBUFSIZ_TINY); - snprintf (output_buf, HCBUFSIZ_TINY - 1, "N/A"); + snprintf (output_buf, HCBUFSIZ_TINY, "N/A"); if (device_param->skipped == true) return output_buf; @@ -1991,7 +1991,7 @@ char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int device_i } else { - snprintf (output_buf, HCBUFSIZ_TINY - 1, "N/A"); + snprintf (output_buf, HCBUFSIZ_TINY, "N/A"); } hc_thread_mutex_unlock (status_ctx->mux_hwmon);