From adaf3f293b566e2ae12285b698ed6d22bbbebb8c Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 18 Jul 2021 12:48:54 -0700 Subject: [PATCH] make const char pointers actually const const char* is a non const pointer that points to const data. Add missing const. Signed-off-by: Rosen Penev --- src/backend.c | 6 +- src/brain.c | 2 +- src/hlfmt.c | 20 ++--- src/mpsp.c | 2 +- src/shared.c | 184 ++++++++++++++++++++++----------------------- src/status.c | 40 +++++----- src/terminal.c | 4 +- src/user_options.c | 20 ++--- 8 files changed, 139 insertions(+), 139 deletions(-) diff --git a/src/backend.c b/src/backend.c index 31d6bade1..6430cef39 100644 --- a/src/backend.c +++ b/src/backend.c @@ -26,10 +26,10 @@ #include "terminal.h" #if defined (__linux__) -static const char *dri_card0_path = "/dev/dri/card0"; +static const char *const dri_card0_path = "/dev/dri/card0"; -static const char *drm_card0_vendor_path = "/sys/class/drm/card0/device/vendor"; -static const char *drm_card0_driver_path = "/sys/class/drm/card0/device/driver"; +static const char *const drm_card0_vendor_path = "/sys/class/drm/card0/device/vendor"; +static const char *const drm_card0_driver_path = "/sys/class/drm/card0/device/driver"; #endif static const u32 full01 = 0x01010101; diff --git a/src/brain.c b/src/brain.c index 2962eaa2e..a12a1375b 100644 --- a/src/brain.c +++ b/src/brain.c @@ -666,7 +666,7 @@ u32 brain_auth_challenge (void) #else - static const char *urandom = "/dev/urandom"; + static const char *const urandom = "/dev/urandom"; HCFILE fp; diff --git a/src/hlfmt.c b/src/hlfmt.c index 0e803445b..be71742e2 100644 --- a/src/hlfmt.c +++ b/src/hlfmt.c @@ -10,16 +10,16 @@ #include "hlfmt.h" #include "shared.h" -static const char *HLFMT_TEXT_HASHCAT = "native hashcat"; -static const char *HLFMT_TEXT_PWDUMP = "pwdump"; -static const char *HLFMT_TEXT_PASSWD = "passwd"; -static const char *HLFMT_TEXT_SHADOW = "shadow"; -static const char *HLFMT_TEXT_DCC = "DCC"; -static const char *HLFMT_TEXT_DCC2 = "DCC 2"; -static const char *HLFMT_TEXT_NETNTLM1 = "NetNTLMv1"; -static const char *HLFMT_TEXT_NETNTLM2 = "NetNTLMv2"; -static const char *HLFMT_TEXT_NSLDAP = "nsldap"; -static const char *HLFMT_TEXT_NSLDAPS = "nsldaps"; +static const char *const HLFMT_TEXT_HASHCAT = "native hashcat"; +static const char *const HLFMT_TEXT_PWDUMP = "pwdump"; +static const char *const HLFMT_TEXT_PASSWD = "passwd"; +static const char *const HLFMT_TEXT_SHADOW = "shadow"; +static const char *const HLFMT_TEXT_DCC = "DCC"; +static const char *const HLFMT_TEXT_DCC2 = "DCC 2"; +static const char *const HLFMT_TEXT_NETNTLM1 = "NetNTLMv1"; +static const char *const HLFMT_TEXT_NETNTLM2 = "NetNTLMv2"; +static const char *const HLFMT_TEXT_NSLDAP = "nsldap"; +static const char *const HLFMT_TEXT_NSLDAPS = "nsldaps"; // hlfmt hashcat diff --git a/src/mpsp.c b/src/mpsp.c index 67168e189..d096b97b5 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -16,7 +16,7 @@ #include "ext_lzma.h" #include "mpsp.h" -static const char *DEF_MASK = "?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d"; +static const char *const DEF_MASK = "?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d"; #define MAX_MFS 5 // 4*charset, 1*mask diff --git a/src/shared.c b/src/shared.c index b101cc01f..7efdd4d53 100644 --- a/src/shared.c +++ b/src/shared.c @@ -15,97 +15,97 @@ #include #endif -static const char *PA_000 = "OK"; -static const char *PA_001 = "Ignored due to comment"; -static const char *PA_002 = "Ignored due to zero length"; -static const char *PA_003 = "Line-length exception"; -static const char *PA_004 = "Hash-length exception"; -static const char *PA_005 = "Hash-value exception"; -static const char *PA_006 = "Salt-length exception"; -static const char *PA_007 = "Salt-value exception"; -static const char *PA_008 = "Salt-iteration count exception"; -static const char *PA_009 = "Separator unmatched"; -static const char *PA_010 = "Signature unmatched"; -static const char *PA_011 = "Invalid hccapx file size"; -static const char *PA_012 = "Invalid hccapx eapol size"; -static const char *PA_013 = "Invalid psafe2 filesize"; -static const char *PA_014 = "Invalid psafe3 filesize"; -static const char *PA_015 = "Invalid truecrypt filesize"; -static const char *PA_016 = "Invalid veracrypt filesize"; -static const char *PA_017 = "Invalid SIP directive, only MD5 is supported"; -static const char *PA_018 = "Hash-file exception"; -static const char *PA_019 = "Hash-encoding exception"; -static const char *PA_020 = "Salt-encoding exception"; -static const char *PA_021 = "Invalid LUKS filesize"; -static const char *PA_022 = "Invalid LUKS identifier"; -static const char *PA_023 = "Invalid LUKS version"; -static const char *PA_024 = "Invalid or unsupported LUKS cipher type"; -static const char *PA_025 = "Invalid or unsupported LUKS cipher mode"; -static const char *PA_026 = "Invalid or unsupported LUKS hash type"; -static const char *PA_027 = "Invalid LUKS key size"; -static const char *PA_028 = "Disabled LUKS key detected"; -static const char *PA_029 = "Invalid LUKS key AF stripes count"; -static const char *PA_030 = "Invalid combination of LUKS hash type and cipher type"; -static const char *PA_031 = "Invalid hccapx signature"; -static const char *PA_032 = "Invalid hccapx version"; -static const char *PA_033 = "Invalid hccapx message pair"; -static const char *PA_034 = "Token encoding exception"; -static const char *PA_035 = "Token length exception"; -static const char *PA_036 = "Insufficient entropy exception"; -static const char *PA_037 = "Hash contains unsupported compression type for current mode"; -static const char *PA_038 = "Invalid key size"; -static const char *PA_039 = "Invalid block size"; -static const char *PA_040 = "Invalid or unsupported cipher"; -static const char *PA_041 = "Invalid filesize"; -static const char *PA_042 = "IV length exception"; -static const char *PA_043 = "CT length exception"; -static const char *PA_255 = "Unknown error"; - -static const char *OPTI_STR_OPTIMIZED_KERNEL = "Optimized-Kernel"; -static const char *OPTI_STR_ZERO_BYTE = "Zero-Byte"; -static const char *OPTI_STR_PRECOMPUTE_INIT = "Precompute-Init"; -static const char *OPTI_STR_MEET_IN_MIDDLE = "Meet-In-The-Middle"; -static const char *OPTI_STR_EARLY_SKIP = "Early-Skip"; -static const char *OPTI_STR_NOT_SALTED = "Not-Salted"; -static const char *OPTI_STR_NOT_ITERATED = "Not-Iterated"; -static const char *OPTI_STR_PREPENDED_SALT = "Prepended-Salt"; -static const char *OPTI_STR_APPENDED_SALT = "Appended-Salt"; -static const char *OPTI_STR_SINGLE_HASH = "Single-Hash"; -static const char *OPTI_STR_SINGLE_SALT = "Single-Salt"; -static const char *OPTI_STR_BRUTE_FORCE = "Brute-Force"; -static const char *OPTI_STR_RAW_HASH = "Raw-Hash"; -static const char *OPTI_STR_SLOW_HASH_SIMD_INIT = "Slow-Hash-SIMD-INIT"; -static const char *OPTI_STR_SLOW_HASH_SIMD_LOOP = "Slow-Hash-SIMD-LOOP"; -static const char *OPTI_STR_SLOW_HASH_SIMD_COMP = "Slow-Hash-SIMD-COMP"; -static const char *OPTI_STR_USES_BITS_8 = "Uses-8-Bit"; -static const char *OPTI_STR_USES_BITS_16 = "Uses-16-Bit"; -static const char *OPTI_STR_USES_BITS_32 = "Uses-32-Bit"; -static const char *OPTI_STR_USES_BITS_64 = "Uses-64-Bit"; - -static const char *HASH_CATEGORY_UNDEFINED_STR = "Undefined"; -static const char *HASH_CATEGORY_RAW_HASH_STR = "Raw Hash"; -static const char *HASH_CATEGORY_RAW_HASH_SALTED_STR = "Raw Hash, Salted and/or Iterated"; -static const char *HASH_CATEGORY_RAW_HASH_AUTHENTICATED_STR = "Raw Hash, Authenticated"; -static const char *HASH_CATEGORY_RAW_CIPHER_KPA_STR = "Raw Cipher, Known-Plaintext attack"; -static const char *HASH_CATEGORY_GENERIC_KDF_STR = "Generic KDF"; -static const char *HASH_CATEGORY_NETWORK_PROTOCOL_STR = "Network Protocols"; -static const char *HASH_CATEGORY_FORUM_SOFTWARE_STR = "Forums, CMS, E-Commerce"; -static const char *HASH_CATEGORY_DATABASE_SERVER_STR = "Database Server"; -static const char *HASH_CATEGORY_NETWORK_SERVER_STR = "FTP, HTTP, SMTP, LDAP Server"; -static const char *HASH_CATEGORY_RAW_CHECKSUM_STR = "Raw Checksum"; -static const char *HASH_CATEGORY_OS_STR = "Operating System"; -static const char *HASH_CATEGORY_EAS_STR = "Enterprise Application Software (EAS)"; -static const char *HASH_CATEGORY_ARCHIVE_STR = "Archives"; -static const char *HASH_CATEGORY_FDE_STR = "Full-Disk Encryption (FDE)"; -static const char *HASH_CATEGORY_FBE_STR = "File-Based Encryption (FBE)"; -static const char *HASH_CATEGORY_DOCUMENTS_STR = "Documents"; -static const char *HASH_CATEGORY_PASSWORD_MANAGER_STR = "Password Managers"; -static const char *HASH_CATEGORY_OTP_STR = "One-Time Passwords"; -static const char *HASH_CATEGORY_PLAIN_STR = "Plaintext"; -static const char *HASH_CATEGORY_FRAMEWORK_STR = "Framework"; -static const char *HASH_CATEGORY_PRIVATE_KEY_STR = "Private Key"; -static const char *HASH_CATEGORY_IMS_STR = "Instant Messaging Service"; -static const char *HASH_CATEGORY_CRYPTOCURRENCY_WALLET_STR = "Cryptocurrency Wallet"; +static const char *const PA_000 = "OK"; +static const char *const PA_001 = "Ignored due to comment"; +static const char *const PA_002 = "Ignored due to zero length"; +static const char *const PA_003 = "Line-length exception"; +static const char *const PA_004 = "Hash-length exception"; +static const char *const PA_005 = "Hash-value exception"; +static const char *const PA_006 = "Salt-length exception"; +static const char *const PA_007 = "Salt-value exception"; +static const char *const PA_008 = "Salt-iteration count exception"; +static const char *const PA_009 = "Separator unmatched"; +static const char *const PA_010 = "Signature unmatched"; +static const char *const PA_011 = "Invalid hccapx file size"; +static const char *const PA_012 = "Invalid hccapx eapol size"; +static const char *const PA_013 = "Invalid psafe2 filesize"; +static const char *const PA_014 = "Invalid psafe3 filesize"; +static const char *const PA_015 = "Invalid truecrypt filesize"; +static const char *const PA_016 = "Invalid veracrypt filesize"; +static const char *const PA_017 = "Invalid SIP directive, only MD5 is supported"; +static const char *const PA_018 = "Hash-file exception"; +static const char *const PA_019 = "Hash-encoding exception"; +static const char *const PA_020 = "Salt-encoding exception"; +static const char *const PA_021 = "Invalid LUKS filesize"; +static const char *const PA_022 = "Invalid LUKS identifier"; +static const char *const PA_023 = "Invalid LUKS version"; +static const char *const PA_024 = "Invalid or unsupported LUKS cipher type"; +static const char *const PA_025 = "Invalid or unsupported LUKS cipher mode"; +static const char *const PA_026 = "Invalid or unsupported LUKS hash type"; +static const char *const PA_027 = "Invalid LUKS key size"; +static const char *const PA_028 = "Disabled LUKS key detected"; +static const char *const PA_029 = "Invalid LUKS key AF stripes count"; +static const char *const PA_030 = "Invalid combination of LUKS hash type and cipher type"; +static const char *const PA_031 = "Invalid hccapx signature"; +static const char *const PA_032 = "Invalid hccapx version"; +static const char *const PA_033 = "Invalid hccapx message pair"; +static const char *const PA_034 = "Token encoding exception"; +static const char *const PA_035 = "Token length exception"; +static const char *const PA_036 = "Insufficient entropy exception"; +static const char *const PA_037 = "Hash contains unsupported compression type for current mode"; +static const char *const PA_038 = "Invalid key size"; +static const char *const PA_039 = "Invalid block size"; +static const char *const PA_040 = "Invalid or unsupported cipher"; +static const char *const PA_041 = "Invalid filesize"; +static const char *const PA_042 = "IV length exception"; +static const char *const PA_043 = "CT length exception"; +static const char *const PA_255 = "Unknown error"; + +static const char *const OPTI_STR_OPTIMIZED_KERNEL = "Optimized-Kernel"; +static const char *const OPTI_STR_ZERO_BYTE = "Zero-Byte"; +static const char *const OPTI_STR_PRECOMPUTE_INIT = "Precompute-Init"; +static const char *const OPTI_STR_MEET_IN_MIDDLE = "Meet-In-The-Middle"; +static const char *const OPTI_STR_EARLY_SKIP = "Early-Skip"; +static const char *const OPTI_STR_NOT_SALTED = "Not-Salted"; +static const char *const OPTI_STR_NOT_ITERATED = "Not-Iterated"; +static const char *const OPTI_STR_PREPENDED_SALT = "Prepended-Salt"; +static const char *const OPTI_STR_APPENDED_SALT = "Appended-Salt"; +static const char *const OPTI_STR_SINGLE_HASH = "Single-Hash"; +static const char *const OPTI_STR_SINGLE_SALT = "Single-Salt"; +static const char *const OPTI_STR_BRUTE_FORCE = "Brute-Force"; +static const char *const OPTI_STR_RAW_HASH = "Raw-Hash"; +static const char *const OPTI_STR_SLOW_HASH_SIMD_INIT = "Slow-Hash-SIMD-INIT"; +static const char *const OPTI_STR_SLOW_HASH_SIMD_LOOP = "Slow-Hash-SIMD-LOOP"; +static const char *const OPTI_STR_SLOW_HASH_SIMD_COMP = "Slow-Hash-SIMD-COMP"; +static const char *const OPTI_STR_USES_BITS_8 = "Uses-8-Bit"; +static const char *const OPTI_STR_USES_BITS_16 = "Uses-16-Bit"; +static const char *const OPTI_STR_USES_BITS_32 = "Uses-32-Bit"; +static const char *const OPTI_STR_USES_BITS_64 = "Uses-64-Bit"; + +static const char *const HASH_CATEGORY_UNDEFINED_STR = "Undefined"; +static const char *const HASH_CATEGORY_RAW_HASH_STR = "Raw Hash"; +static const char *const HASH_CATEGORY_RAW_HASH_SALTED_STR = "Raw Hash, Salted and/or Iterated"; +static const char *const HASH_CATEGORY_RAW_HASH_AUTHENTICATED_STR = "Raw Hash, Authenticated"; +static const char *const HASH_CATEGORY_RAW_CIPHER_KPA_STR = "Raw Cipher, Known-Plaintext attack"; +static const char *const HASH_CATEGORY_GENERIC_KDF_STR = "Generic KDF"; +static const char *const HASH_CATEGORY_NETWORK_PROTOCOL_STR = "Network Protocols"; +static const char *const HASH_CATEGORY_FORUM_SOFTWARE_STR = "Forums, CMS, E-Commerce"; +static const char *const HASH_CATEGORY_DATABASE_SERVER_STR = "Database Server"; +static const char *const HASH_CATEGORY_NETWORK_SERVER_STR = "FTP, HTTP, SMTP, LDAP Server"; +static const char *const HASH_CATEGORY_RAW_CHECKSUM_STR = "Raw Checksum"; +static const char *const HASH_CATEGORY_OS_STR = "Operating System"; +static const char *const HASH_CATEGORY_EAS_STR = "Enterprise Application Software (EAS)"; +static const char *const HASH_CATEGORY_ARCHIVE_STR = "Archives"; +static const char *const HASH_CATEGORY_FDE_STR = "Full-Disk Encryption (FDE)"; +static const char *const HASH_CATEGORY_FBE_STR = "File-Based Encryption (FBE)"; +static const char *const HASH_CATEGORY_DOCUMENTS_STR = "Documents"; +static const char *const HASH_CATEGORY_PASSWORD_MANAGER_STR = "Password Managers"; +static const char *const HASH_CATEGORY_OTP_STR = "One-Time Passwords"; +static const char *const HASH_CATEGORY_PLAIN_STR = "Plaintext"; +static const char *const HASH_CATEGORY_FRAMEWORK_STR = "Framework"; +static const char *const HASH_CATEGORY_PRIVATE_KEY_STR = "Private Key"; +static const char *const HASH_CATEGORY_IMS_STR = "Instant Messaging Service"; +static const char *const HASH_CATEGORY_CRYPTOCURRENCY_WALLET_STR = "Cryptocurrency Wallet"; int sort_by_string_sized (const void *p1, const void *p2) { @@ -1062,7 +1062,7 @@ static int rounds_count_length (const char *input_buf, const int input_len) { if (input_len >= 9) // 9 is minimum because of "rounds=X$" { - static const char *rounds = "rounds="; + static const char *const rounds = "rounds="; if (memcmp (input_buf, rounds, 7) == 0) { diff --git a/src/status.c b/src/status.c index 6b4084b59..c26e43e51 100644 --- a/src/status.c +++ b/src/status.c @@ -18,29 +18,29 @@ #include "shared.h" #include "status.h" -static const char *ST_0000 = "Initializing"; -static const char *ST_0001 = "Autotuning"; -static const char *ST_0002 = "Selftest"; -static const char *ST_0003 = "Running"; -static const char *ST_0004 = "Paused"; -static const char *ST_0005 = "Exhausted"; -static const char *ST_0006 = "Cracked"; -static const char *ST_0007 = "Aborted"; -static const char *ST_0008 = "Quit"; -static const char *ST_0009 = "Bypass"; -static const char *ST_0010 = "Aborted (Checkpoint)"; -static const char *ST_0011 = "Aborted (Runtime)"; -static const char *ST_0012 = "Running (Checkpoint Quit requested)"; -static const char *ST_0013 = "Error"; -static const char *ST_0014 = "Aborted (Finish)"; -static const char *ST_0015 = "Running (Quit after attack requested)"; -static const char *ST_0016 = "Autodetect"; -static const char *ST_9999 = "Unknown! Bug!"; +static const char *const ST_0000 = "Initializing"; +static const char *const ST_0001 = "Autotuning"; +static const char *const ST_0002 = "Selftest"; +static const char *const ST_0003 = "Running"; +static const char *const ST_0004 = "Paused"; +static const char *const ST_0005 = "Exhausted"; +static const char *const ST_0006 = "Cracked"; +static const char *const ST_0007 = "Aborted"; +static const char *const ST_0008 = "Quit"; +static const char *const ST_0009 = "Bypass"; +static const char *const ST_0010 = "Aborted (Checkpoint)"; +static const char *const ST_0011 = "Aborted (Runtime)"; +static const char *const ST_0012 = "Running (Checkpoint Quit requested)"; +static const char *const ST_0013 = "Error"; +static const char *const ST_0014 = "Aborted (Finish)"; +static const char *const ST_0015 = "Running (Quit after attack requested)"; +static const char *const ST_0016 = "Autodetect"; +static const char *const ST_9999 = "Unknown! Bug!"; static const char UNITS[7] = { ' ', 'k', 'M', 'G', 'T', 'P', 'E' }; -static const char *ETA_ABSOLUTE_MAX_EXCEEDED = "Next Big Bang"; // in honor of ighashgpu -static const char *ETA_RELATIVE_MAX_EXCEEDED = "> 10 years"; +static const char *const ETA_ABSOLUTE_MAX_EXCEEDED = "Next Big Bang"; // in honor of ighashgpu +static const char *const ETA_RELATIVE_MAX_EXCEEDED = "> 10 years"; static char *status_get_rules_file (const hashcat_ctx_t *hashcat_ctx) { diff --git a/src/terminal.c b/src/terminal.c index b72e7d9e4..d4bc98b4e 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -19,8 +19,8 @@ static const size_t TERMINAL_LINE_LENGTH = 79; -static const char *PROMPT_ACTIVE = "[s]tatus [p]ause [b]ypass [c]heckpoint [f]inish [q]uit => "; -static const char *PROMPT_PAUSED = "[s]tatus [r]esume [b]ypass [c]heckpoint [f]inish [q]uit => "; +static const char *const PROMPT_ACTIVE = "[s]tatus [p]ause [b]ypass [c]heckpoint [f]inish [q]uit => "; +static const char *const PROMPT_PAUSED = "[s]tatus [r]esume [b]ypass [c]heckpoint [f]inish [q]uit => "; void welcome_screen (hashcat_ctx_t *hashcat_ctx, const char *version_tag) { diff --git a/src/user_options.c b/src/user_options.c index 14a75c8bd..77d989376 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -20,12 +20,12 @@ #endif #ifdef WITH_BRAIN -static const char *short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMSz"; +static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMSz"; #else -static const char *short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMS"; +static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMS"; #endif -static char *SEPARATOR = ":"; +static char *const SEPARATOR = ":"; static const struct option long_options[] = { @@ -147,15 +147,15 @@ static const struct option long_options[] = {NULL, 0, NULL, 0 } }; -static const char *ENCODING_FROM = "utf-8"; -static const char *ENCODING_TO = "utf-8"; +static const char *const ENCODING_FROM = "utf-8"; +static const char *const ENCODING_TO = "utf-8"; -static const char *RULE_BUF_R = ":"; -static const char *RULE_BUF_L = ":"; +static const char *const RULE_BUF_R = ":"; +static const char *const RULE_BUF_L = ":"; -static const char *DEF_MASK_CS_1 = "?l?d?u"; -static const char *DEF_MASK_CS_2 = "?l?d"; -static const char *DEF_MASK_CS_3 = "?l?d*!$@_"; +static const char *const DEF_MASK_CS_1 = "?l?d?u"; +static const char *const DEF_MASK_CS_2 = "?l?d"; +static const char *const DEF_MASK_CS_3 = "?l?d*!$@_"; int user_options_init (hashcat_ctx_t *hashcat_ctx) {