From ef6b20cc308598f4bdb4af86c342833de823ba15 Mon Sep 17 00:00:00 2001 From: philsmd Date: Sat, 18 Nov 2017 12:18:56 +0100 Subject: [PATCH] increase HCBUFSIZ_LARGE and truncate too large strings when copied to old_buf in events --- docs/changes.txt | 6 ++++++ include/common.h | 2 +- src/event.c | 12 ++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 372f55a5e..1ab4e2dea 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -13,6 +13,12 @@ - Fixed a hash parsing problem when using --show/--left together with hashes with long salts that require pure kernels - Fixed the output of --show if $HEX[] passwords are present within the potfile +## +## Technical +## + +- Changed the way large strings are handled/truncated within the event buffer if they are too large to fit + * changes v4.0.0 -> v4.0.1: ## diff --git a/include/common.h b/include/common.h index 45d3019bb..ac5e17dda 100644 --- a/include/common.h +++ b/include/common.h @@ -104,7 +104,7 @@ but this is nededed for VS compiler which doesn't have inline keyword but has __ #define SALT_MAX_OLD 51 #define HCBUFSIZ_TINY 0x1000 -#define HCBUFSIZ_LARGE 0x50000 +#define HCBUFSIZ_LARGE 0xb0000 #define CPT_CACHE 0x20000 #define PARAMCNT 64 diff --git a/src/event.c b/src/event.c index eb20d114e..3073a97f8 100644 --- a/src/event.c +++ b/src/event.c @@ -45,12 +45,20 @@ void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, cons event_ctx->old_len[i] = event_ctx->old_len[i - 1]; } + u32 copy_len = 0; + if (buf) { - memcpy (event_ctx->old_buf[0], buf, len); + // truncate the whole buffer if needed (such that it fits into the old_buf): + + const u32 max_buf_len = sizeof (event_ctx->old_buf[0]); + + copy_len = MIN (len, max_buf_len - 1); + + memcpy (event_ctx->old_buf[0], buf, copy_len); } - event_ctx->old_len[0] = len; + event_ctx->old_len[0] = copy_len; } }