From c9b16d76e6fa43c8a60ce24e2c70b44176877513 Mon Sep 17 00:00:00 2001 From: philsmd Date: Tue, 28 Nov 2017 16:31:04 +0100 Subject: [PATCH] self-tests: always work with copies of the self-test hash --- src/hashes.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hashes.c b/src/hashes.c index 28e9d37de..2bdd1df3c 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -1671,7 +1671,14 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx) } } - parser_status = hashconfig->parse_func ((u8 *) hashconfig->st_hash, strlen (hashconfig->st_hash), &hash, hashconfig_st); + // Make sure that we do not modify constant data. Make a copy of the constant self-test hash + // Note: sometimes parse_func () modifies the data internally. We always need to use a copy of the original data + + char *tmpdata = hcstrdup (hashconfig->st_hash); + + parser_status = hashconfig->parse_func ((u8 *) tmpdata, strlen (hashconfig->st_hash), &hash, hashconfig_st); + + hcfree (tmpdata); hcfree (hashconfig_st); }