Skip to content

Commit

Permalink
Checking received data size and reject if not match.
Browse files Browse the repository at this point in the history
We dont need to panic in this case, fetchData can handle this.

Signed-off-by: Xiaoxi Chen <[email protected]>
  • Loading branch information
xiaoxichen committed Nov 11, 2024
1 parent 3882211 commit a7682ed
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib/replication/repl_dev/raft_repl_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,12 @@ void RaftReplDev::on_push_data_received(intrusive< sisl::GenericRpcData >& rpc_d
auto const fb_size =
flatbuffers::ReadScalar< flatbuffers::uoffset_t >(incoming_buf.cbytes()) + sizeof(flatbuffers::uoffset_t);
auto push_req = GetSizePrefixedPushDataRequest(incoming_buf.cbytes());
HS_DBG_ASSERT_EQ(fb_size + push_req->data_size(), incoming_buf.size(), "Size mismatch of data size vs buffer size");

if (fb_size + push_req->data_size() != incoming_buf.size()) {
RD_LOGW("Data Channel: PushData received with size mismatch, header size {}, data size {}, received size {}",
fb_size, push_req->data_size(), incoming_buf.size());
rpc_data->send_response();
return;
}
sisl::blob header = sisl::blob{push_req->user_header()->Data(), push_req->user_header()->size()};
sisl::blob key = sisl::blob{push_req->user_key()->Data(), push_req->user_key()->size()};
repl_key rkey{.server_id = push_req->issuer_replica_id(), .term = push_req->raft_term(), .dsn = push_req->dsn()};
Expand Down

0 comments on commit a7682ed

Please sign in to comment.