ggpo: Fix udp packet size. Fix verif mismatch due to uninit'ed var

This commit is contained in:
Flyinghead 2021-10-15 13:07:21 +02:00
parent c08f177d3b
commit 7ecb6a6d96
3 changed files with 4 additions and 3 deletions

View File

@ -15,7 +15,7 @@
#define MAX_UDP_ENDPOINTS 16
static const int MAX_UDP_PACKET_SIZE = 4096;
constexpr size_t MAX_UDP_PACKET_SIZE = sizeof(UdpMsg);
class Udp : public IPollSink
{

View File

@ -69,7 +69,7 @@ struct UdpMsg
uint16 num_bits;
uint8 input_size; // XXX: shouldn't be in every single packet!
uint8 bits[MAX_COMPRESSED_BITS]; /* must be last */
uint8 bits[MAX_COMPRESSED_BITS / 8]; /* must be last */
} input;
struct {

View File

@ -487,7 +487,8 @@ UdpProtocol::OnSyncRequest(UdpMsg *msg, int len)
}
UdpMsg *reply = new UdpMsg(UdpMsg::SyncReply);
reply->u.sync_reply.random_reply = msg->u.sync_request.random_request;
// Calculate incoming verif data size
msg->verification_size = 0;
int msgVerifSize = len - msg->PacketSize();
if (msgVerifSize != (int)verification.size()
|| (msgVerifSize != 0 && memcmp(&msg->u.sync_request.verification[0], &verification[0], msgVerifSize)))