From 5a54cb6c8288535b401b2d178701185b4b6771ed Mon Sep 17 00:00:00 2001 From: Abhinav Anil Sharma Date: Wed, 22 Nov 2023 09:18:40 -0500 Subject: [PATCH] Subtract encoding entry size in raw2trace too --- clients/drcachesim/tracer/raw2trace.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/drcachesim/tracer/raw2trace.cpp b/clients/drcachesim/tracer/raw2trace.cpp index 2a00d91060c..b3a44ddd557 100644 --- a/clients/drcachesim/tracer/raw2trace.cpp +++ b/clients/drcachesim/tracer/raw2trace.cpp @@ -364,12 +364,12 @@ module_mapper_t::do_encoding_parsing() uint64_t cumulative_encoding_length = 0; while (map_at < map_end) { encoding_entry_t *entry = reinterpret_cast(map_at); - if (entry->length < sizeof(encoding_entry_t)) + if (entry->length <= sizeof(encoding_entry_t)) return "Encoding file is corrupted"; if (map_at + entry->length > map_end) return "Encoding file is truncated"; cum_block_enc_len_to_encoding_id_[cumulative_encoding_length] = entry->id; - cumulative_encoding_length += entry->length; + cumulative_encoding_length += (entry->length - sizeof(encoding_entry_t)); encodings_[entry->id] = entry; map_at += entry->length; }