Fix component extra empty array exploit (#82)

This commit is contained in:
Luna 2023-05-29 19:59:58 -03:00 committed by GitHub
parent 08930195bb
commit ae17467c1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Mon, 29 May 2023 19:34:50 -0300
Subject: [PATCH] Fix component extra empty array exploit
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
index 534f1e6092d2b64b6e6e3182eac0cc38718ab2f8..7fcab29427ea030c0d9dcb6ce237b67d98420b55 100644
--- a/src/main/java/net/minecraft/network/chat/Component.java
+++ b/src/main/java/net/minecraft/network/chat/Component.java
@@ -322,6 +322,11 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
if (!jsonelement.isJsonObject()) {
if (jsonelement.isJsonArray()) {
JsonArray jsonarray = jsonelement.getAsJsonArray();
+ // Scissors start
+ if (jsonarray.size() <= 0) {
+ throw new JsonParseException("Unexpected empty array of components");
+ }
+ // Scissors end
ichatmutablecomponent = null;
Iterator iterator = jsonarray.iterator();