mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-22 08:08:10 +00:00
Filehandling: Print a truncation warning in case an oversized line was detected
This commit is contained in:
parent
1ecdffb580
commit
97c9e86d15
@ -82,6 +82,7 @@
|
||||
- Building: Updated BUILD.md
|
||||
- Cracking bcrypt and Password Safe v2: Use a feedback from the compute API backend to dynamically find out optimal thread count
|
||||
- Documents: Added README on how to build hashcat on MSYS2
|
||||
- Filehandling: Print a truncation warning in case an oversized line was detected
|
||||
- My Wallet: Added additional plaintext pattern used in newer versions
|
||||
- OpenCL Runtime: Disable OpenCL kernel cache on Apple for Intel CPU (throws CL_BUILD_PROGRAM_FAILURE for no reason)
|
||||
- OpenCL Runtime: Do not run a shared- and constant-memory size check if their memory type is of type global memory (typically CPU)
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#if defined (__CYGWIN__)
|
||||
int _wopen (const char *path, int oflag, ...);
|
||||
@ -31,7 +32,7 @@ char *hc_fgets (char *buf, int len, HCFILE *fp);
|
||||
size_t hc_fwrite (void *ptr, size_t size, size_t nmemb, HCFILE *fp);
|
||||
size_t hc_fread (void *ptr, size_t size, size_t nmemb, HCFILE *fp);
|
||||
|
||||
size_t fgetl (HCFILE *fp, char *line_buf);
|
||||
size_t fgetl (HCFILE *fp, char *line_buf, const size_t line_sz);
|
||||
u64 count_lines (HCFILE *fp);
|
||||
size_t in_superchop (char *buf);
|
||||
size_t superchop_with_length (char *buf, const size_t len);
|
||||
|
@ -4183,7 +4183,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co
|
||||
{
|
||||
if (hc_feof (combs_fp)) break;
|
||||
|
||||
size_t line_len = fgetl (combs_fp, line_buf);
|
||||
size_t line_len = fgetl (combs_fp, line_buf, HCBUFSIZ_LARGE);
|
||||
|
||||
line_len = convert_from_hex (hashcat_ctx, line_buf, line_len);
|
||||
|
||||
@ -4328,7 +4328,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co
|
||||
{
|
||||
if (hc_feof (combs_fp)) break;
|
||||
|
||||
size_t line_len = fgetl (combs_fp, line_buf);
|
||||
size_t line_len = fgetl (combs_fp, line_buf, HCBUFSIZ_LARGE);
|
||||
|
||||
line_len = convert_from_hex (hashcat_ctx, line_buf, line_len);
|
||||
|
||||
|
@ -454,8 +454,10 @@ void hc_fclose (HCFILE *fp)
|
||||
fp->mode = NULL;
|
||||
}
|
||||
|
||||
size_t fgetl (HCFILE *fp, char *line_buf)
|
||||
size_t fgetl (HCFILE *fp, char *line_buf, const size_t line_sz)
|
||||
{
|
||||
size_t line_truncated = 0;
|
||||
|
||||
size_t line_len = 0;
|
||||
|
||||
while (!hc_feof (fp))
|
||||
@ -464,15 +466,25 @@ size_t fgetl (HCFILE *fp, char *line_buf)
|
||||
|
||||
if (c == EOF) break;
|
||||
|
||||
if (line_len == line_sz)
|
||||
{
|
||||
line_truncated++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
line_buf[line_len] = (char) c;
|
||||
|
||||
line_len++;
|
||||
|
||||
if (line_len == HCBUFSIZ_LARGE) line_len--;
|
||||
|
||||
if (c == '\n') break;
|
||||
}
|
||||
|
||||
if (line_truncated > 0)
|
||||
{
|
||||
fprintf (stderr, "\nOversized line detected! Truncated %" PRIu64 " bytes\n", line_truncated);
|
||||
}
|
||||
|
||||
if (line_len == 0) return 0;
|
||||
|
||||
while (line_len)
|
||||
|
@ -1018,7 +1018,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
line_num++;
|
||||
|
||||
const size_t line_len = fgetl (&fp, line_buf);
|
||||
const size_t line_len = fgetl (&fp, line_buf, HCBUFSIZ_LARGE);
|
||||
|
||||
if (line_len == 0) continue;
|
||||
|
||||
|
@ -350,7 +350,7 @@ u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, u32 max_check)
|
||||
|
||||
while (!hc_feof (fp))
|
||||
{
|
||||
const size_t line_len = fgetl (fp, line_buf);
|
||||
const size_t line_len = fgetl (fp, line_buf, HCBUFSIZ_LARGE);
|
||||
|
||||
if (line_len == 0) continue;
|
||||
|
||||
|
@ -30,7 +30,7 @@ bool initialize_keyboard_layout_mapping (const char *filename, keyboard_layout_m
|
||||
|
||||
while (!hc_feof (&fp))
|
||||
{
|
||||
const size_t line_len = fgetl (&fp, line_buf);
|
||||
const size_t line_len = fgetl (&fp, line_buf, HCBUFSIZ_LARGE);
|
||||
|
||||
if (line_len == 0) continue;
|
||||
|
||||
|
@ -1434,7 +1434,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
while (!hc_feof (&mask_fp))
|
||||
{
|
||||
const size_t line_len = fgetl (&mask_fp, line_buf);
|
||||
const size_t line_len = fgetl (&mask_fp, line_buf, HCBUFSIZ_LARGE);
|
||||
|
||||
if (line_len == 0) continue;
|
||||
|
||||
@ -1519,7 +1519,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
while (!hc_feof (&mask_fp))
|
||||
{
|
||||
const size_t line_len = fgetl (&mask_fp, line_buf);
|
||||
const size_t line_len = fgetl (&mask_fp, line_buf, HCBUFSIZ_LARGE);
|
||||
|
||||
if (line_len == 0) continue;
|
||||
|
||||
@ -1589,7 +1589,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
while (!hc_feof (&mask_fp))
|
||||
{
|
||||
const size_t line_len = fgetl (&mask_fp, line_buf);
|
||||
const size_t line_len = fgetl (&mask_fp, line_buf, HCBUFSIZ_LARGE);
|
||||
|
||||
if (line_len == 0) continue;
|
||||
|
||||
|
@ -185,7 +185,7 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
while (!hc_feof (&fp))
|
||||
{
|
||||
size_t line_len = fgetl (&fp, line_buf);
|
||||
size_t line_len = fgetl (&fp, line_buf, HCBUFSIZ_LARGE);
|
||||
|
||||
if (line_len == 0) continue;
|
||||
|
||||
|
@ -521,7 +521,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
while (!hc_feof (&potfile_ctx->fp))
|
||||
{
|
||||
size_t line_len = fgetl (&potfile_ctx->fp, line_buf);
|
||||
size_t line_len = fgetl (&potfile_ctx->fp, line_buf, HCBUFSIZ_LARGE);
|
||||
|
||||
if (line_len == 0) continue;
|
||||
|
||||
|
2
src/rp.c
2
src/rp.c
@ -751,7 +751,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32
|
||||
|
||||
while (!hc_feof (&fp))
|
||||
{
|
||||
rule_len = (u32) fgetl (&fp, rule_buf);
|
||||
rule_len = (u32) fgetl (&fp, rule_buf, HCBUFSIZ_LARGE);
|
||||
|
||||
rule_line++;
|
||||
|
||||
|
@ -123,7 +123,7 @@ void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u
|
||||
|
||||
while (1)
|
||||
{
|
||||
line_len = (u32) fgetl (combs_fp, line_buf);
|
||||
line_len = (u32) fgetl (combs_fp, line_buf, HCBUFSIZ_LARGE);
|
||||
|
||||
// post-process rule engine
|
||||
|
||||
@ -286,7 +286,7 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info)
|
||||
|
||||
while (1)
|
||||
{
|
||||
line_len = (u32) fgetl (combs_fp, line_buf);
|
||||
line_len = (u32) fgetl (combs_fp, line_buf, HCBUFSIZ_LARGE);
|
||||
|
||||
// post-process rule engine
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user