Skip to content

Commit ac86d04

Browse files
rubenwardynerzhul
authored andcommitted
Fix detach inventory serialisation (#8331)
1 parent 82c6363 commit ac86d04

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/network/clientpackethandler.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,10 @@ void Client::handleCommand_DetachedInventory(NetworkPacket* pkt)
895895
inv = inv_it->second;
896896
}
897897

898-
std::string contents;
899-
*pkt >> contents;
898+
u16 ignore;
899+
*pkt >> ignore; // this used to be the length of the following string, ignore it
900+
901+
std::string contents = pkt->getRemainingString();
900902
std::istringstream is(contents, std::ios::binary);
901903
inv->deSerialize(is);
902904
}

src/server.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2576,7 +2576,10 @@ void Server::sendDetachedInventory(const std::string &name, session_t peer_id)
25762576
// Serialization & NetworkPacket isn't a love story
25772577
std::ostringstream os(std::ios_base::binary);
25782578
inv_it->second->serialize(os);
2579-
pkt << os.str();
2579+
2580+
std::string os_str = os.str();
2581+
pkt << static_cast<u16>(os_str.size()); // HACK: to keep compatibility with 5.0.0 clients
2582+
pkt.putRawString(os_str);
25802583
}
25812584

25822585
if (peer_id == PEER_ID_INEXISTENT)

0 commit comments

Comments
 (0)