From f317ba327ce2727fc4e42338d890ab7ae6ef20b5 Mon Sep 17 00:00:00 2001 From: TheLastRar Date: Tue, 3 Dec 2024 22:28:12 +0000 Subject: [PATCH] DEV9: Correct alignment calculation in Sockets --- pcsx2/DEV9/PacketReader/IP/IP_Packet.cpp | 5 +++-- pcsx2/DEV9/PacketReader/IP/TCP/TCP_Packet.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pcsx2/DEV9/PacketReader/IP/IP_Packet.cpp b/pcsx2/DEV9/PacketReader/IP/IP_Packet.cpp index 713eb16391..8b6ce41895 100644 --- a/pcsx2/DEV9/PacketReader/IP/IP_Packet.cpp +++ b/pcsx2/DEV9/PacketReader/IP/IP_Packet.cpp @@ -4,6 +4,7 @@ #include "IP_Packet.h" #include "DEV9/PacketReader/NetLib.h" +#include "common/BitUtils.h" #include "common/Console.h" namespace PacketReader::IP @@ -209,8 +210,8 @@ namespace PacketReader::IP for (size_t i = 0; i < options.size(); i++) opOffset += options[i]->GetLength(); - opOffset += opOffset % 4; //needs to be a whole number of 32bits - headerLength = opOffset; + //needs to be a whole number of 32bits + headerLength = Common::AlignUpPow2(opOffset, 4); } void IP_Packet::CalculateChecksum() diff --git a/pcsx2/DEV9/PacketReader/IP/TCP/TCP_Packet.cpp b/pcsx2/DEV9/PacketReader/IP/TCP/TCP_Packet.cpp index bd04627a23..c8d6971f6e 100644 --- a/pcsx2/DEV9/PacketReader/IP/TCP/TCP_Packet.cpp +++ b/pcsx2/DEV9/PacketReader/IP/TCP/TCP_Packet.cpp @@ -4,6 +4,7 @@ #include "TCP_Packet.h" #include "DEV9/PacketReader/NetLib.h" +#include "common/BitUtils.h" #include "common/Console.h" namespace PacketReader::IP::TCP @@ -232,8 +233,8 @@ namespace PacketReader::IP::TCP for (size_t i = 0; i < options.size(); i++) opOffset += options[i]->GetLength(); - opOffset += opOffset % 4; //needs to be a whole number of 32bits - headerLength = opOffset; + //needs to be a whole number of 32bits + headerLength = Common::AlignUpPow2(opOffset, 4); //Also write into dataOffsetAndNS_Flag u8 ns = dataOffsetAndNS_Flag & 1;