From 7ecb6a6d967ff42df34c43a43b008bf8df1c53ba Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Fri, 15 Oct 2021 13:07:21 +0200 Subject: [PATCH] ggpo: Fix udp packet size. Fix verif mismatch due to uninit'ed var --- core/deps/ggpo/lib/ggpo/network/udp.h | 2 +- core/deps/ggpo/lib/ggpo/network/udp_msg.h | 2 +- core/deps/ggpo/lib/ggpo/network/udp_proto.cpp | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/deps/ggpo/lib/ggpo/network/udp.h b/core/deps/ggpo/lib/ggpo/network/udp.h index f0ab0f6f1..7af07d8c0 100644 --- a/core/deps/ggpo/lib/ggpo/network/udp.h +++ b/core/deps/ggpo/lib/ggpo/network/udp.h @@ -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 { diff --git a/core/deps/ggpo/lib/ggpo/network/udp_msg.h b/core/deps/ggpo/lib/ggpo/network/udp_msg.h index 852461118..70304188d 100644 --- a/core/deps/ggpo/lib/ggpo/network/udp_msg.h +++ b/core/deps/ggpo/lib/ggpo/network/udp_msg.h @@ -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 { diff --git a/core/deps/ggpo/lib/ggpo/network/udp_proto.cpp b/core/deps/ggpo/lib/ggpo/network/udp_proto.cpp index 41a5b7eeb..2765ace94 100644 --- a/core/deps/ggpo/lib/ggpo/network/udp_proto.cpp +++ b/core/deps/ggpo/lib/ggpo/network/udp_proto.cpp @@ -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)))