Waterfall/BungeeCord-Patches/0010-Don-t-access-a-ByteBuf-s-underlying-array.patch
Shane Freeder c21eed1f7b
Updated Upstream (BungeeCord)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

BungeeCord Changes:
70370faf Add checkstyle indentation checks
24a53a67 Show socketAddress in BungeeServerInfo.toString
503b4827 Fix bad formatting in EntityMap
eeb37479 #2710: Store queue of pending keepalives
3f6aa033 Also check that things that should not be padded are so
78a84953 Add more checkstyle rules
636c0207 #2753: Add configurable remote ping caching
a4512e50 Check Maven version in action build & don't print noisy transfer progress
f510989c Add building of pull requests via GitHub Actions
2020-01-24 22:41:39 +00:00

91 lines
4.9 KiB
Diff

From f773ac3808fea1fb04889bb30f3c89539cf1d6f0 Mon Sep 17 00:00:00 2001
From: Techcable <Techcable@techcable.net>
Date: Tue, 3 May 2016 20:31:52 -0700
Subject: [PATCH] Don't access a ByteBuf's underlying array
It returns the underlying array storage, and does *not* return a view of the buffer as an array
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java
index c01cf317..17e12655 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java
@@ -4,6 +4,7 @@ import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil; // Waterfall
import java.io.ByteArrayInputStream;
import java.io.DataInput;
import java.io.DataInputStream;
@@ -56,10 +57,23 @@ public class PluginMessage extends DefinedPacket
return ( input.getTag().equals( "REGISTER" ) || input.getTag().equals( "minecraft:register" ) || input.getTag().equals( "MC|Brand" ) || input.getTag().equals( "minecraft:brand" ) ) && input.getData().length < Byte.MAX_VALUE;
}
};
- //
+
+ public PluginMessage(String tag, ByteBuf data, boolean allowExtendedPacket) {
+ this(tag, ByteBufUtil.getBytes(data), allowExtendedPacket);
+ }
+
private String tag;
private byte[] data;
+ public void setData(byte[] data) {
+ this.data = Preconditions.checkNotNull(data, "Null data");
+ }
+
+ public void setData(ByteBuf buf) {
+ Preconditions.checkNotNull(buf, "Null buffer");
+ setData(ByteBufUtil.getBytes(buf));
+ }
+
/**
* Allow this packet to be sent as an "extended" packet.
*/
diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
index 2ebfef5e..15b9e66c 100644
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
@@ -218,7 +218,7 @@ public class ServerConnector extends PacketHandler
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand );
- user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", DefinedPacket.toArray( brand ), handshakeHandler.isServerForge() ) );
+ user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler.isServerForge() ) );
brand.release();
user.setDimension( login.getDimension() );
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
index e53a3ff9..99e7376b 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
@@ -261,7 +261,7 @@ public class DownstreamBridge extends PacketHandler
brand = ByteBufAllocator.DEFAULT.heapBuffer();
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")" + " <- " + serverBrand, brand );
- pluginMessage.setData( DefinedPacket.toArray( brand ) );
+ pluginMessage.setData( brand );
brand.release();
// changes in the packet are ignored so we need to send it manually
con.unsafe().sendPacket( pluginMessage );
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
index 44e28846..c5f071f2 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
@@ -48,9 +48,9 @@ import net.md_5.bungee.protocol.Varint21LengthFieldPrepender;
public class PipelineUtils
{
- public static final AttributeKey<ListenerInfo> LISTENER = AttributeKey.valueOf( "ListerInfo" );
- public static final AttributeKey<UserConnection> USER = AttributeKey.valueOf( "User" );
- public static final AttributeKey<BungeeServerInfo> TARGET = AttributeKey.valueOf( "Target" );
+ public static final AttributeKey<ListenerInfo> LISTENER = AttributeKey.newInstance("ListerInfo");
+ public static final AttributeKey<UserConnection> USER = AttributeKey.newInstance("User");
+ public static final AttributeKey<BungeeServerInfo> TARGET = AttributeKey.newInstance("Target");
public static final ChannelInitializer<Channel> SERVER_CHILD = new ChannelInitializer<Channel>()
{
@Override
--
2.25.0