summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2016-05-22 10:04:41 +0000
committerfrosch <frosch@openttd.org>2016-05-22 10:04:41 +0000
commit97e6981e39154d293056567bae84bac7f3202125 (patch)
treed34d4b9a6d4df047097c6a37c60f99dd3409fb8e /src/network
parent46b7ac7b487f1c3519a94a9dacc5ca0d64f279ed (diff)
downloadopenttd-97e6981e39154d293056567bae84bac7f3202125.tar.xz
(svn r27570) -Fix [FS#6449]: Various incorrect but uncritical size computations in the content client.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_content.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp
index 174dbdafe..1a186826a 100644
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -57,7 +57,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p)
ci->filesize = p->Recv_uint32();
p->Recv_string(ci->name, lengthof(ci->name));
- p->Recv_string(ci->version, lengthof(ci->name));
+ p->Recv_string(ci->version, lengthof(ci->version));
p->Recv_string(ci->url, lengthof(ci->url));
p->Recv_string(ci->description, lengthof(ci->description), SVS_REPLACE_WITH_QUESTION_MARK | SVS_ALLOW_NEWLINE);
@@ -220,10 +220,9 @@ void ClientNetworkContentSocketHandler::RequestContentList(uint count, const Con
while (count > 0) {
/* We can "only" send a limited number of IDs in a single packet.
* A packet begins with the packet size and a byte for the type.
- * Then this packet adds a byte for the content type and a uint16
- * for the count in this packet. The rest of the packet can be
- * used for the IDs. */
- uint p_count = min(count, (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(byte) - sizeof(uint16)) / sizeof(uint32));
+ * Then this packet adds a uint16 for the count in this packet.
+ * The rest of the packet can be used for the IDs. */
+ uint p_count = min(count, (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint16)) / sizeof(uint32));
Packet *p = new Packet(PACKET_CONTENT_CLIENT_INFO_ID);
p->Send_uint16(p_count);
@@ -249,9 +248,9 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
this->Connect();
- /* 20 is sizeof(uint32) + sizeof(md5sum (byte[16])) */
assert(cv->Length() < 255);
- assert(cv->Length() < (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) / (send_md5sum ? 20 : sizeof(uint32)));
+ assert(cv->Length() < (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) /
+ (sizeof(uint8) + sizeof(uint32) + (send_md5sum ? sizeof(ContentInfo::md5sum) : 0)));
Packet *p = new Packet(send_md5sum ? PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 : PACKET_CONTENT_CLIENT_INFO_EXTID);
p->Send_uint8(cv->Length());