Updated hpfs hash verification with file mode checks. (#257)

* Added file mode to hpfs responses.

* Parse file mode on hpfs response read.

* Apply file/dir mode.

* Fixed mode apply logic.

* Fixed code review comments.

* Additional fix.
This commit is contained in:
Ravin Perera
2021-02-24 11:13:28 +05:30
committed by GitHub
parent 363116fc2a
commit 5b56d9c1b3
13 changed files with 201 additions and 80 deletions

View File

@@ -380,11 +380,12 @@ namespace msg::fbuf::p2pmsg
}
void create_msg_from_fsentry_response(
flatbuffers::FlatBufferBuilder &builder, const std::string_view path, const uint32_t mount_id,
std::vector<hpfs::child_hash_node> &hash_nodes, util::h32 expected_hash)
flatbuffers::FlatBufferBuilder &builder, const std::string_view path, const uint32_t mount_id, const mode_t dir_mode,
std::vector<hpfs::child_hash_node> &hash_nodes, const util::h32 &expected_hash)
{
const auto child_msg = CreateHpfsFsEntryResponse(
builder,
dir_mode,
hpfsfshashentry_to_flatbuf_hpfsfshashentry(builder, hash_nodes));
const auto msg = CreateHpfsResponseMsg(
@@ -400,13 +401,14 @@ namespace msg::fbuf::p2pmsg
void create_msg_from_filehashmap_response(
flatbuffers::FlatBufferBuilder &builder, std::string_view path, const uint32_t mount_id,
std::vector<util::h32> &hashmap, std::size_t file_length, util::h32 expected_hash)
std::vector<util::h32> &hashmap, const std::size_t file_length, const mode_t file_mode, const util::h32 &expected_hash)
{
std::string_view hashmap_sv(reinterpret_cast<const char *>(hashmap.data()), hashmap.size() * sizeof(util::h32));
const auto child_msg = CreateHpfsFileHashMapResponse(
builder,
file_length,
file_mode,
sv_to_flatbuf_bytes(builder, hashmap_sv));
const auto msg = CreateHpfsResponseMsg(