mirror of
https://github.com/lax1dude/eaglerxserver
synced 2025-06-05 15:51:59 -09:00
Fix OOM vulnerability in protocol module
This commit is contained in:
parent
6588c2dfed
commit
b7eae2199f
@ -153,12 +153,24 @@ public class ByteBufInputWrapper implements GamePacketInputBuffer {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated(forRemoval = true)
|
||||
public byte[] readByteArrayMC() throws IOException {
|
||||
byte[] abyte = new byte[BufferUtils.readVarInt(buffer, 5)];
|
||||
buffer.readBytes(abyte);
|
||||
return abyte;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] readByteArrayMC(int maxLen) throws IOException {
|
||||
int i = BufferUtils.readVarInt(buffer, 5);
|
||||
if (i > maxLen) {
|
||||
throw new IOException("Byte array is too long: " + i + " > " + maxLen);
|
||||
}
|
||||
byte[] abyte = new byte[i];
|
||||
buffer.readBytes(abyte);
|
||||
return abyte;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
return buffer.readableBytes();
|
||||
|
@ -34,8 +34,11 @@ public interface GamePacketInputBuffer extends DataInput {
|
||||
|
||||
String readStringEaglerASCII16() throws IOException;
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
byte[] readByteArrayMC() throws IOException;
|
||||
|
||||
byte[] readByteArrayMC(int maxLen) throws IOException;
|
||||
|
||||
int available() throws IOException;
|
||||
|
||||
InputStream stream();
|
||||
|
@ -53,7 +53,7 @@ public class CPacketWebViewMessageV4EAG implements GameMessagePacket {
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
type = buffer.readUnsignedByte();
|
||||
data = buffer.readByteArrayMC();
|
||||
data = buffer.readByteArrayMC(32750);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,7 +53,7 @@ public class SPacketWebViewMessageV4EAG implements GameMessagePacket {
|
||||
@Override
|
||||
public void readPacket(GamePacketInputBuffer buffer) throws IOException {
|
||||
type = buffer.readUnsignedByte();
|
||||
data = buffer.readByteArrayMC();
|
||||
data = buffer.readByteArrayMC(32750);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -171,12 +171,24 @@ public class SimpleInputBufferImpl extends DataInputStream implements GamePacket
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated(forRemoval = true)
|
||||
public byte[] readByteArrayMC() throws IOException {
|
||||
byte[] abyte = new byte[this.readVarInt()];
|
||||
this.readFully(abyte);
|
||||
return abyte;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] readByteArrayMC(int maxLen) throws IOException {
|
||||
int i = this.readVarInt();
|
||||
if (i > maxLen) {
|
||||
throw new IOException("Byte array is too long: " + i + " > " + maxLen);
|
||||
}
|
||||
byte[] abyte = new byte[i];
|
||||
this.readFully(abyte);
|
||||
return abyte;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream stream() {
|
||||
return in;
|
||||
|
Loading…
x
Reference in New Issue
Block a user