Add returncode PARSER_HAVE_ERRNO as a valid returncode from module_hash_binary_count() and module_hash_binary_parse() module hooks. You can use this in case fopen() fails and you want to transport back the original error from the OS

This commit is contained in:
Jens Steube
2020-05-27 15:23:02 +02:00
parent bb19c9cf1b
commit 84d3981e7b
40 changed files with 58 additions and 46 deletions
+1
View File
@@ -539,6 +539,7 @@ typedef enum parser_rc
PARSER_BLOCK_SIZE = -39,
PARSER_CIPHER = -40,
PARSER_FILE_SIZE = -41,
PARSER_HAVE_ERRNO = -100,
PARSER_UNKNOWN_ERROR = -255
} parser_rc_t;
+15 -4
View File
@@ -735,21 +735,28 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
{
const int binary_count = module_ctx->module_hash_binary_count (hashes);
if (binary_count == 0)
if (binary_count > 0)
{
hashes_avail = binary_count;
}
else if (binary_count == 0)
{
event_log_error (hashcat_ctx, "No hashes loaded.");
return -1;
}
if (binary_count == -1)
else if (binary_count == PARSER_HAVE_ERRNO)
{
event_log_error (hashcat_ctx, "%s: %s", hashes->hashfile, strerror (errno));
return -1;
}
else
{
event_log_error (hashcat_ctx, "%s: %s", hashes->hashfile, strerror (binary_count));
hashes_avail = binary_count;
return -1;
}
}
else
{
@@ -1289,6 +1296,10 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
hashes_cnt = hashes_parsed;
}
else if (hashes_parsed == 0)
{
event_log_warning (hashcat_ctx, "No hashes loaded.");
}
else if (hashes_parsed == PARSER_HAVE_ERRNO)
{
event_log_warning (hashcat_ctx, "Hashfile '%s': %s", hashes->hashfile, strerror (errno));
}
+2 -2
View File
@@ -376,7 +376,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return -1;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
char *in = (char *) hcmalloc (sizeof (hccapx_t));
@@ -467,7 +467,7 @@ int module_hash_binary_count (MAYBE_UNUSED const hashes_t *hashes)
{
struct stat st;
if (stat (hashes->hashfile, &st) == -1) return -1;
if (stat (hashes->hashfile, &st) == -1) return (PARSER_HAVE_ERRNO);
return st.st_size / sizeof (hccapx_t);
}
+2 -2
View File
@@ -351,7 +351,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return -1;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
char *in = (char *) hcmalloc (sizeof (hccapx_t));
@@ -442,7 +442,7 @@ int module_hash_binary_count (MAYBE_UNUSED const hashes_t *hashes)
{
struct stat st;
if (stat (hashes->hashfile, &st) == -1) return -1;
if (stat (hashes->hashfile, &st) == -1) return (PARSER_HAVE_ERRNO);
return st.st_size / sizeof (hccapx_t);
}
+1 -1
View File
@@ -155,7 +155,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define TC_HEADER_SIZE 512
+1 -1
View File
@@ -155,7 +155,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define TC_HEADER_SIZE 512
+1 -1
View File
@@ -153,7 +153,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define TC_HEADER_SIZE 512
+1 -1
View File
@@ -137,7 +137,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define TC_HEADER_SIZE 512
+1 -1
View File
@@ -137,7 +137,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define TC_HEADER_SIZE 512
+1 -1
View File
@@ -135,7 +135,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define TC_HEADER_SIZE 512
+1 -1
View File
@@ -136,7 +136,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define TC_HEADER_SIZE 512
+1 -1
View File
@@ -136,7 +136,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define TC_HEADER_SIZE 512
+1 -1
View File
@@ -136,7 +136,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define TC_HEADER_SIZE 512
+1 -1
View File
@@ -149,7 +149,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define TC_HEADER_SIZE 512
+1 -1
View File
@@ -149,7 +149,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define TC_HEADER_SIZE 512
+1 -1
View File
@@ -149,7 +149,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define TC_HEADER_SIZE 512
+1 -1
View File
@@ -165,7 +165,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -165,7 +165,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -165,7 +165,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -166,7 +166,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -166,7 +166,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -166,7 +166,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -165,7 +165,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -165,7 +165,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -165,7 +165,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -167,7 +167,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -167,7 +167,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -167,7 +167,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -184,7 +184,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -184,7 +184,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -184,7 +184,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -186,7 +186,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -186,7 +186,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -186,7 +186,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -169,7 +169,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -169,7 +169,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -169,7 +169,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
#define VC_HEADER_SIZE 512
+1 -1
View File
@@ -377,7 +377,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
HCFILE fp;
if (hc_fopen (&fp, (const char *) line_buf, "rb") == false) return (PARSER_HASH_FILE);
if (hc_fopen (&fp, (const char *) line_buf, "rb") == false) return (PARSER_HAVE_ERRNO);
struct luks_phdr hdr;
+2 -2
View File
@@ -171,7 +171,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return -1;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
const bool r = is_hccapx (&fp);
@@ -258,7 +258,7 @@ int module_hash_binary_count (MAYBE_UNUSED const hashes_t *hashes)
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return -1;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
const bool r = is_hccapx (&fp);
+2 -2
View File
@@ -172,7 +172,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return -1;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
const bool r = is_hccapx (&fp);
@@ -259,7 +259,7 @@ int module_hash_binary_count (MAYBE_UNUSED const hashes_t *hashes)
HCFILE fp;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return -1;
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO);
const bool r = is_hccapx (&fp);