PaperMC/Paper/GH-166

This commit is contained in:
Zach Brown 2016-03-29 23:29:14 -05:00
parent 010c651473
commit 4c7641d191
2 changed files with 89 additions and 0 deletions

View File

@ -4074,6 +4074,47 @@ index 0000000..f75e2de
+
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketLoginInEncryptionBegin.java b/src/main/java/net/minecraft/server/PacketLoginInEncryptionBegin.java
new file mode 100644
index 0000000..1d2e855
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketLoginInEncryptionBegin.java
@@ -0,0 +1,35 @@
+package net.minecraft.server;
+
+import java.io.IOException;
+import java.security.PrivateKey;
+import javax.crypto.SecretKey;
+
+public class PacketLoginInEncryptionBegin implements Packet<PacketLoginInListener> {
+
+ private byte[] a = new byte[0];
+ private byte[] b = new byte[0];
+
+ public PacketLoginInEncryptionBegin() {}
+
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
+ this.a = packetdataserializer.a();
+ this.b = packetdataserializer.a();
+ }
+
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
+ packetdataserializer.a(this.a);
+ packetdataserializer.a(this.b);
+ }
+
+ public void a(PacketLoginInListener packetlogininlistener) {
+ packetlogininlistener.a(this);
+ }
+
+ public SecretKey a(PrivateKey privatekey) {
+ return MinecraftEncryption.a(privatekey, this.a);
+ }
+
+ public byte[] b(PrivateKey privatekey) {
+ return privatekey == null ? this.b : MinecraftEncryption.b(privatekey, this.b);
+ }
+}
--
2.7.1

View File

@ -0,0 +1,48 @@
From dc74220050b2649edcd76d58e5becfe9f8280d9d Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Tue, 29 Mar 2016 23:20:10 -0500
Subject: [PATCH] PaperMC/Paper/GH-166
diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
index f426c2e..e2eb305 100644
--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
+++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
@@ -46,8 +46,16 @@ public class PacketDataSerializer extends ByteBuf {
this.writeBytes(abyte);
}
+ // Paper start
public byte[] a() {
- byte[] abyte = new byte[this.e()];
+ return readByteArray(Short.MAX_VALUE);
+ }
+
+ public byte[]readByteArray(int limit) {
+ int len = this.e();
+ if (len > limit) throw new DecoderException("The received a byte array longer than allowed " + len + " > " + limit);
+ byte[] abyte = new byte[len];
+ // Paper end
this.readBytes(abyte);
return abyte;
diff --git a/src/main/java/net/minecraft/server/PacketLoginInEncryptionBegin.java b/src/main/java/net/minecraft/server/PacketLoginInEncryptionBegin.java
index 1d2e855..da9d4d8 100644
--- a/src/main/java/net/minecraft/server/PacketLoginInEncryptionBegin.java
+++ b/src/main/java/net/minecraft/server/PacketLoginInEncryptionBegin.java
@@ -12,8 +12,10 @@ public class PacketLoginInEncryptionBegin implements Packet<PacketLoginInListene
public PacketLoginInEncryptionBegin() {}
public void a(PacketDataSerializer packetdataserializer) throws IOException {
- this.a = packetdataserializer.a();
- this.b = packetdataserializer.a();
+ // Paper start
+ this.a = packetdataserializer.readByteArray(256);
+ this.b = packetdataserializer.readByteArray(256);
+ // Paper end
}
public void b(PacketDataSerializer packetdataserializer) throws IOException {
--
2.7.4