Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
Fix for CVE-2021-33790
Browse files Browse the repository at this point in the history
This code will be removed and refactored in 1.17
  • Loading branch information
modmuss50 committed May 30, 2021
1 parent 2d3c46b commit a7c2a41
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
sourceCompatibility = 1.8
targetCompatibility = 1.8

version = "4.7.2"
version = "4.7.3"
group = 'RebornCore'

def ENV = System.getenv()
Expand Down
24 changes: 14 additions & 10 deletions src/main/java/reborncore/common/network/ExtendedPacketBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.Tag;
import net.minecraft.network.PacketByteBuf;
import org.apache.commons.io.serialization.ValidatingObjectInputStream;
import reborncore.RebornCore;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.math.BigInteger;

Expand All @@ -52,23 +54,25 @@ protected Object readObject() {
return ObjectBufferUtils.readObject(this);
}

@Deprecated // Remove in 1.17
public void writeBigInt(BigInteger bigInteger) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
ObjectOutputStream outputStream = new ObjectOutputStream(baos);
outputStream.writeObject(bigInteger);
writeByteArray(baos.toByteArray());
} catch (Exception e) {
throw new RuntimeException("Failed to write big int");
} catch (IOException e) {
RebornCore.LOGGER.error(e);
}
}

public BigInteger readBigInt() {
try {
ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(readByteArray()));
@Deprecated // Remove in 1.17
public BigInteger readBigInt(){
try (ValidatingObjectInputStream inputStream = new ValidatingObjectInputStream(new ByteArrayInputStream(readByteArray()))) {
inputStream.accept(BigInteger.class);
return (BigInteger) inputStream.readObject();
} catch (Exception e) {
throw new RuntimeException("Failed to read big int");
} catch (IOException | ClassNotFoundException e) {
RebornCore.LOGGER.error(e);
return BigInteger.ZERO;
}
}

Expand Down

0 comments on commit a7c2a41

Please sign in to comment.