From 2434380da2c7b1af1233f6b22034e44abeb5390e Mon Sep 17 00:00:00 2001 From: Sein Coray Date: Tue, 14 May 2019 14:00:18 +0200 Subject: [PATCH] fixed printing of hash for module 17220 and 17230 using the u32 data array --- src/modules/module_17220.c | 12 ++++++++++-- src/modules/module_17230.c | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/modules/module_17220.c b/src/modules/module_17220.c index f6fe0d12c..989c509ee 100644 --- a/src/modules/module_17220.c +++ b/src/modules/module_17220.c @@ -308,6 +308,10 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE for (int cnt = 0; cnt < pkzip->hash_count; cnt++) { + if (cnt > 0) + { + out_len += sprintf (line_buf + out_len, "*"); + } out_len += sprintf (line_buf + out_len, "%i*%i*", pkzip->hashes[cnt].data_type_enum, pkzip->hashes[cnt].magic_type_enum); if (pkzip->hashes[cnt].data_type_enum > 1) { @@ -320,9 +324,13 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE out_len += sprintf (line_buf + out_len, "%x*", pkzip->hashes[cnt].checksum_from_timestamp); } - for (u32 i = 0; i < pkzip->hashes[cnt].data_length; i++) + for (u32 i = 0; i < pkzip->hashes[cnt].data_length / 4; i++) { - out_len += sprintf (line_buf + out_len, "%02x", pkzip->hashes[cnt].data[i]); + out_len += sprintf (line_buf + out_len, "%08x", byte_swap_32 (pkzip->hashes[cnt].data[i])); + } + for (u32 i = 0; i < pkzip->hashes[cnt].data_length % 4; i++) + { + out_len += sprintf (line_buf + out_len, "%02x", (pkzip->hashes[cnt].data[pkzip->hashes[cnt].data_length / 4] >> i*8) & 0xff); } } diff --git a/src/modules/module_17230.c b/src/modules/module_17230.c index d9f3ebbfd..41d9270a0 100644 --- a/src/modules/module_17230.c +++ b/src/modules/module_17230.c @@ -309,6 +309,10 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE for (int cnt = 0; cnt < pkzip->hash_count; cnt++) { + if (cnt > 0) + { + out_len += sprintf (line_buf + out_len, "*"); + } out_len += sprintf (line_buf + out_len, "%i*%i*", pkzip->hashes[cnt].data_type_enum, pkzip->hashes[cnt].magic_type_enum); if (pkzip->hashes[cnt].data_type_enum > 1) { @@ -321,9 +325,13 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE out_len += sprintf (line_buf + out_len, "%x*", pkzip->hashes[cnt].checksum_from_timestamp); } - for (u32 i = 0; i < pkzip->hashes[cnt].data_length; i++) + for (u32 i = 0; i < pkzip->hashes[cnt].data_length / 4; i++) { - out_len += sprintf (line_buf + out_len, "%02x", pkzip->hashes[cnt].data[i]); + out_len += sprintf (line_buf + out_len, "%08x", byte_swap_32 (pkzip->hashes[cnt].data[i])); + } + for (u32 i = 0; i < pkzip->hashes[cnt].data_length % 4; i++) + { + out_len += sprintf (line_buf + out_len, "%02x", (pkzip->hashes[cnt].data[pkzip->hashes[cnt].data_length / 4] >> i*8) & 0xff); } }