From e2066b79194a448da6e138b860808d0ad26342f7 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 29 Oct 2016 23:11:38 +0200 Subject: [PATCH] Fix more missing zero-byte termination in outfile.c --- src/outfile.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/outfile.c b/src/outfile.c index 2a8e5e35c..d632f1607 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -190,6 +190,8 @@ int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl } } + plain_ptr[plain_len] = 0; + *out_len = plain_len; return 0; @@ -197,13 +199,13 @@ int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl int build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u64 *out_pos) { - combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; - mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; - straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; - user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + const combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; + const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - const u32 gidvid = plain->gidvid; - const u32 il_pos = plain->il_pos; + const u32 gidvid = plain->gidvid; + const u32 il_pos = plain->il_pos; u64 crackpos = device_param->words_off; @@ -233,12 +235,12 @@ int build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, int build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u8 *debug_rule_buf, int *debug_rule_len, u8 *debug_plain_ptr, int *debug_plain_len) { - debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx; - straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; - user_options_t *user_options = hashcat_ctx->user_options; + const debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx; + const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; - const u32 gidvid = plain->gidvid; - const u32 il_pos = plain->il_pos; + const u32 gidvid = plain->gidvid; + const u32 il_pos = plain->il_pos; if (user_options->attack_mode != ATTACK_MODE_STRAIGHT) return 0; @@ -259,7 +261,11 @@ int build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param // save rule if ((debug_mode == 1) || (debug_mode == 3) || (debug_mode == 4)) { - *debug_rule_len = kernel_rule_to_cpu_rule ((char *) debug_rule_buf, &straight_ctx->kernel_rules_buf[off]); + const int len = kernel_rule_to_cpu_rule ((char *) debug_rule_buf, &straight_ctx->kernel_rules_buf[off]); + + debug_rule_buf[len] = 0; + + *debug_rule_len = len; } // save plain @@ -267,6 +273,8 @@ int build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param { memcpy (debug_plain_ptr, (char *) pw.i, (size_t) plain_len); + debug_plain_ptr[plain_len] = 0; + *debug_plain_len = plain_len; }