Skip to content

Commit 0cb844a

Browse files
Fix mod detection vulnerability
1 parent 4f51706 commit 0cb844a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/main/java/net/wurstclient/WurstTranslator.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.function.BiConsumer;
1919

2020
import com.google.common.collect.Lists;
21+
import com.google.gson.JsonParseException;
2122

2223
import net.minecraft.client.Minecraft;
2324
import net.minecraft.client.resources.language.ClientLanguage;
@@ -187,15 +188,25 @@ private void loadTranslations(ResourceManager manager,
187188
ResourceLocation langId =
188189
ResourceLocation.fromNamespaceAndPath("wurst", langFilePath);
189190

191+
// IMPORTANT: Exceptions thrown by Language.loadFromJson() must
192+
// be caught to prevent mod detection vulnerabilities using
193+
// intentionally corrupted resource packs.
190194
for(Resource resource : manager.getResourceStack(langId))
191195
try(InputStream stream = resource.open())
192196
{
193197
Language.loadFromJson(stream, entryConsumer);
194198

195-
}catch(IOException e)
199+
}catch(IOException | JsonParseException e)
196200
{
197-
System.out.println("Failed to load translations for "
198-
+ langCode + " from pack " + resource.sourcePackId());
201+
System.out.println(
202+
"Failed to load Wurst translations for " + langCode);
203+
e.printStackTrace();
204+
205+
}catch(Exception e)
206+
{
207+
System.out.println(
208+
"Unexpected exception while loading Wurst translations for "
209+
+ langCode);
199210
e.printStackTrace();
200211
}
201212
}

0 commit comments

Comments
 (0)