diff --git a/src/modules/module_17200.c b/src/modules/module_17200.c index 516a7c9e5..fff5e9c82 100644 --- a/src/modules/module_17200.c +++ b/src/modules/module_17200.c @@ -125,7 +125,7 @@ struct pkzip_hash u32 data_length; u16 checksum_from_crc; u16 checksum_from_timestamp; - u8 data[MAX_DATA]; + u32 data[MAX_DATA]; } __attribute__((packed)); @@ -227,7 +227,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE p = strtok(NULL, "*"); if (p == NULL) return PARSER_HASH_LENGTH; pkzip->hash.uncompressed_length = strtoul(p, NULL, 16); - if (pkzip->hash.compressed_length > MAX_DATA) + if (pkzip->hash.compressed_length > MAX_DATA * 4) { return PARSER_TOKEN_LENGTH; } @@ -321,9 +321,13 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE out_len += sprintf (line_buf + out_len, "%x*", pkzip->hash.checksum_from_timestamp); } - for (u32 i = 0; i < pkzip->hash.data_length; i++) + for (u32 i = 0; i < pkzip->hash.data_length / 4; i++) { - out_len += sprintf (line_buf + out_len, "%02x", pkzip->hash.data[i]); + out_len += sprintf (line_buf + out_len, "%08x", byte_swap_32 (pkzip->hash.data[i])); + } + for (u32 i = 0; i < pkzip->hash.data_length % 4; i++) + { + out_len += sprintf (line_buf + out_len, "%02x", (pkzip->hash.data[pkzip->hash.data_length / 4] >> i*8) & 0xff); } if (pkzip->version == 1) diff --git a/src/modules/module_17210.c b/src/modules/module_17210.c index 64f235991..3ef59834e 100644 --- a/src/modules/module_17210.c +++ b/src/modules/module_17210.c @@ -125,7 +125,7 @@ struct pkzip_hash u32 data_length; u16 checksum_from_crc; u16 checksum_from_timestamp; - u8 data[MAX_DATA]; + u32 data[MAX_DATA]; } __attribute__((packed)); @@ -227,7 +227,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE p = strtok(NULL, "*"); if (p == NULL) return PARSER_HASH_LENGTH; pkzip->hash.uncompressed_length = strtoul(p, NULL, 16); - if (pkzip->hash.uncompressed_length > MAX_DATA) + if (pkzip->hash.uncompressed_length > MAX_DATA * 4) { return PARSER_TOKEN_LENGTH; } @@ -309,24 +309,25 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE } out_len += sprintf (line_buf + out_len, "%i*%i*", pkzip->hash_count, pkzip->checksum_size); - for (int cnt = 0; cnt < pkzip->hash_count; cnt++) + out_len += sprintf (line_buf + out_len, "%i*%i*", pkzip->hash.data_type_enum, pkzip->hash.magic_type_enum); + if (pkzip->hash.data_type_enum > 1) { - out_len += sprintf (line_buf + out_len, "%i*%i*", pkzip->hash.data_type_enum, pkzip->hash.magic_type_enum); - if (pkzip->hash.data_type_enum > 1) - { - out_len += sprintf (line_buf + out_len, "%x*%x*%x*%x*%x*", pkzip->hash.compressed_length, pkzip->hash.uncompressed_length, pkzip->hash.crc32, pkzip->hash.offset, pkzip->hash.additional_offset); - } + out_len += sprintf (line_buf + out_len, "%x*%x*%x*%x*%x*", pkzip->hash.compressed_length, pkzip->hash.uncompressed_length, pkzip->hash.crc32, pkzip->hash.offset, pkzip->hash.additional_offset); + } - out_len += sprintf (line_buf + out_len, "%i*%x*%x*", pkzip->hash.compression_type, pkzip->hash.data_length, pkzip->hash.checksum_from_crc); - if (pkzip->version == 2) - { - out_len += sprintf (line_buf + out_len, "%x*", pkzip->hash.checksum_from_timestamp); - } + out_len += sprintf (line_buf + out_len, "%i*%x*%x*", pkzip->hash.compression_type, pkzip->hash.data_length, pkzip->hash.checksum_from_crc); + if (pkzip->version == 2) + { + out_len += sprintf (line_buf + out_len, "%x*", pkzip->hash.checksum_from_timestamp); + } - for (u32 i = 0; i < pkzip->hash.data_length; i++) - { - out_len += sprintf (line_buf + out_len, "%02x", pkzip->hash.data[i]); - } + for (u32 i = 0; i < pkzip->hash.data_length / 4; i++) + { + out_len += sprintf (line_buf + out_len, "%08x", byte_swap_32 (pkzip->hash.data[i])); + } + for (u32 i = 0; i < pkzip->hash.data_length % 4; i++) + { + out_len += sprintf (line_buf + out_len, "%02x", (pkzip->hash.data[pkzip->hash.data_length / 4] >> i*8) & 0xff); } if (pkzip->version == 1) diff --git a/src/modules/module_17230.c b/src/modules/module_17230.c index 41d9270a0..ed01166e5 100644 --- a/src/modules/module_17230.c +++ b/src/modules/module_17230.c @@ -125,7 +125,7 @@ struct pkzip_hash u32 data_length; u16 checksum_from_crc; u16 checksum_from_timestamp; - u8 data[MAX_DATA]; + u32 data[MAX_DATA]; } __attribute__((packed)); @@ -230,7 +230,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE p = strtok(NULL, "*"); if (p == NULL) return PARSER_HASH_LENGTH; pkzip->hashes[i].uncompressed_length = strtoul(p, NULL, 16); - if (pkzip->hashes[i].compressed_length > MAX_DATA) + if (pkzip->hashes[i].compressed_length > MAX_DATA * 4) { return PARSER_TOKEN_LENGTH; }