mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-30 13:08:19 +01:00
Prevent framed packets from being corrupted
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
581c97e2ba
commit
8f1e84ffdb
@ -252,7 +252,7 @@ public class PlayerSocketConnection extends PlayerConnection {
|
||||
}
|
||||
|
||||
public void write(@NotNull FramedPacket framedPacket) {
|
||||
write(framedPacket.body().flip());
|
||||
write(framedPacket.body().position(0));
|
||||
}
|
||||
|
||||
public void write(@NotNull ServerPacket packet) {
|
||||
|
@ -109,7 +109,7 @@ public final class PacketUtils {
|
||||
// Send grouped packet...
|
||||
if (!PACKET_LISTENER_MANAGER.processServerPacket(packet, players))
|
||||
return;
|
||||
final ByteBuffer finalBuffer = createFramedPacket(packet);
|
||||
final ByteBuffer finalBuffer = createFramedPacket(packet).flip();
|
||||
final FramedPacket framedPacket = new FramedPacket(packet.getId(), finalBuffer, packet);
|
||||
// Send packet to all players
|
||||
for (Player player : players) {
|
||||
@ -228,7 +228,8 @@ public final class PacketUtils {
|
||||
@ApiStatus.Internal
|
||||
public static FramedPacket allocateTrimmedPacket(@NotNull ServerPacket packet) {
|
||||
final ByteBuffer temp = PacketUtils.createFramedPacket(packet).flip();
|
||||
final ByteBuffer buffer = ByteBuffer.allocateDirect(temp.remaining()).put(temp).asReadOnlyBuffer();
|
||||
final ByteBuffer buffer = ByteBuffer.allocateDirect(temp.remaining())
|
||||
.put(temp).flip().asReadOnlyBuffer();
|
||||
return new FramedPacket(packet.getId(), buffer, packet);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user