diff --git a/tools/core/flow.h b/tools/core/flow.h index 43b59eb6..562f5384 100644 --- a/tools/core/flow.h +++ b/tools/core/flow.h @@ -192,6 +192,11 @@ class Flow { return IndexError_ReadData; } + if (!data_ptr) { + LOG_ERROR("Invalid data pointer for tag list header"); + return IndexError_ReadData; + } + memcpy(&taglist_header, data_ptr, sizeof(TagListHeader)); auto segment_taglist_key = storage->get(TAGLIST_KEY_SEGMENT_NAME); @@ -209,6 +214,11 @@ class Flow { return IndexError_ReadData; } + if (!data_ptr) { + LOG_ERROR("Invalid data pointer for tag list key"); + return IndexError_ReadData; + } + uint64_t key = *reinterpret_cast(data_ptr); tag_key_list_.push_back(key); @@ -231,6 +241,11 @@ class Flow { return IndexError_ReadData; } + if (!data_ptr) { + LOG_ERROR("Invalid data pointer for tag list offset"); + return IndexError_ReadData; + } + uint64_t tag_offset = *reinterpret_cast(data_ptr); taglist_offsets.push_back(tag_offset); @@ -246,6 +261,11 @@ class Flow { } offset += sizeof(uint64_t); + if (!data_ptr) { + LOG_ERROR("Invalid data pointer for tag count"); + return IndexError_ReadData; + } + uint64_t tag_count = *reinterpret_cast(data_ptr); if (segment_taglist_data->read(offset, (const void **)(&data_ptr), diff --git a/tools/core/helper.h b/tools/core/helper.h index 037958e5..1fa916a4 100644 --- a/tools/core/helper.h +++ b/tools/core/helper.h @@ -221,6 +221,11 @@ int load_taglists(const std::string &path, return IndexError_ReadData; } + if (!data_ptr) { + LOG_ERROR("Invalid data pointer for tag list header"); + return IndexError_ReadData; + } + memcpy(&taglist_header, data_ptr, sizeof(TagListHeader)); auto segment_taglist_key = storage->get(TAGLIST_KEY_SEGMENT_NAME); @@ -238,6 +243,11 @@ int load_taglists(const std::string &path, return IndexError_ReadData; } + if (!data_ptr) { + LOG_ERROR("Invalid data pointer for tag list key"); + return IndexError_ReadData; + } + uint64_t key = *reinterpret_cast(data_ptr); tag_key_list.push_back(key); @@ -260,6 +270,11 @@ int load_taglists(const std::string &path, return IndexError_ReadData; } + if (!data_ptr) { + LOG_ERROR("Invalid data pointer for tag list offset"); + return IndexError_ReadData; + } + uint64_t tag_offset = *reinterpret_cast(data_ptr); taglist_offsets.push_back(tag_offset); @@ -275,6 +290,11 @@ int load_taglists(const std::string &path, } offset += sizeof(uint64_t); + if (!data_ptr) { + LOG_ERROR("Invalid data pointer for tag count"); + return IndexError_ReadData; + } + uint64_t tag_count = *reinterpret_cast(data_ptr); if (segment_taglist_data->read(offset, (const void **)(&data_ptr),