Skip to content

Commit 7450e80

Browse files
committed
LOG4J2-3201 PATCH
1 parent ab7e22f commit 7450e80

3 files changed

Lines changed: 78 additions & 20 deletions

File tree

patches/net/minecraft/client/main/Main.java.patch

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
--- a/net/minecraft/client/main/Main.java
22
+++ b/net/minecraft/client/main/Main.java
3-
@@ -1,5 +1,7 @@
3+
@@ -1,5 +1,8 @@
44
package net.minecraft.client.main;
55

66
+import carpet.spark.CarpetSparkAccess;
7+
+import carpet.utils.Log4j2JndiPatch;
78
+import carpet.worldedit.CarpetWorldEditAccess;
89
import com.google.gson.Gson;
910
import com.google.gson.GsonBuilder;
1011
import com.mojang.authlib.properties.PropertyMap;
11-
@@ -70,6 +72,11 @@
12+
@@ -70,6 +73,11 @@
1213
System.out.println("Completely ignored arguments: " + list);
1314
}
1415

@@ -20,3 +21,13 @@
2021
String s = func_206236_a(optionset, optionspec5);
2122
Proxy proxy = Proxy.NO_PROXY;
2223

24+
@@ -162,6 +170,9 @@
25+
26+
static
27+
{
28+
+ // TISCM LOG4J2-3201 PATCH
29+
+ Log4j2JndiPatch.patch();
30+
+
31+
System.setProperty("java.awt.headless", "true");
32+
}
33+
}

patches/net/minecraft/server/MinecraftServer.java.patch

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- a/net/minecraft/server/MinecraftServer.java
22
+++ b/net/minecraft/server/MinecraftServer.java
3-
@@ -1,5 +1,19 @@
3+
@@ -1,5 +1,20 @@
44
package net.minecraft.server;
55

66
+import carpet.CarpetServer;
@@ -14,21 +14,22 @@
1414
+import carpet.settings.CarpetSettings;
1515
+import carpet.spark.CarpetSparkAccess;
1616
+import carpet.utils.CarpetProfiler;
17+
+import carpet.utils.Log4j2JndiPatch;
1718
+import carpet.utils.Messenger;
1819
+import carpet.utils.TISCMConfig;
1920
+import carpet.worldedit.CarpetWorldEditAccess;
2021
import com.google.common.base.Stopwatch;
2122
import com.google.common.collect.Lists;
2223
import com.google.common.collect.Maps;
23-
@@ -178,6 +192,7 @@
24+
@@ -178,6 +193,7 @@
2425
public final Queue < FutureTask<? >> futureTaskQueue = Queues.newConcurrentLinkedQueue();
2526
private Thread serverThread;
2627
private long serverTime = Util.milliTime();
2728
+ public long actualServerTime = Util.milliTime();
2829
@OnlyIn(Dist.CLIENT)
2930
private boolean worldIconSet;
3031
private final IReloadableResourceManager resourceManager = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA);
31-
@@ -212,6 +227,8 @@
32+
@@ -212,6 +228,8 @@
3233
this.resourceManager.addReloadListener(this.lootTableManager);
3334
this.resourceManager.addReloadListener(this.functionManager);
3435
this.resourceManager.addReloadListener(this.advancementManager);
@@ -37,7 +38,7 @@
3738
}
3839

3940
public abstract boolean init() throws IOException;
40-
@@ -571,7 +588,13 @@
41+
@@ -571,7 +589,13 @@
4142
public void stopServer()
4243
{
4344
LOGGER.info("Stopping server");
@@ -51,7 +52,7 @@
5152
if (this.getNetworkSystem() != null)
5253
{
5354
this.getNetworkSystem().terminateEndpoints();
54-
@@ -639,34 +662,64 @@
55+
@@ -639,34 +663,64 @@
5556
{
5657
try
5758
{
@@ -133,7 +134,7 @@
133134
}
134135
}
135136
else
136-
@@ -782,7 +835,16 @@
137+
@@ -782,7 +836,16 @@
137138
{
138139
long i = Util.nanoTime();
139140
++this.tickCounter;
@@ -150,7 +151,7 @@
150151
if (this.startProfiling)
151152
{
152153
this.startProfiling = false;
153-
@@ -790,6 +852,9 @@
154+
@@ -790,6 +853,9 @@
154155
}
155156

156157
this.profiler.startSection("root");
@@ -160,7 +161,7 @@
160161
this.updateTimeLightAndEntities(hasTimeLeft);
161162

162163
if (i - this.nanoTimeSinceStatusRefresh >= 5000000000L)
163-
@@ -810,10 +875,26 @@
164+
@@ -810,10 +876,26 @@
164165

165166
if (this.tickCounter % 900 == 0)
166167
{
@@ -187,7 +188,7 @@
187188
}
188189

189190
this.profiler.startSection("snooper");
190-
@@ -829,16 +910,30 @@
191+
@@ -829,16 +911,30 @@
191192
}
192193

193194
this.profiler.endSection();
@@ -218,23 +219,23 @@
218219
FutureTask<?> futuretask;
219220

220221
while ((futuretask = this.futureTaskQueue.poll()) != null)
221-
@@ -847,6 +942,7 @@
222+
@@ -847,6 +943,7 @@
222223
}
223224

224225
this.profiler.endStartSection("commandFunctions");
225226
+ MicroTimingLoggerManager.setTickStage(TickStage.COMMAND_FUNCTION); // TISCM Micro Timing logger
226227
this.getFunctionManager().tick();
227228
this.profiler.endStartSection("levels");
228229

229-
@@ -870,6 +966,7 @@
230+
@@ -870,6 +967,7 @@
230231

231232
this.profiler.startSection("tick");
232233

233234
+ // Update suppression fix
234235
try
235236
{
236237
worldserver.tick(hasTimeLeft);
237-
@@ -878,9 +975,15 @@
238+
@@ -878,9 +976,15 @@
238239
{
239240
CrashReport crashreport = CrashReport.makeCrashReport(throwable1, "Exception ticking world");
240241
worldserver.fillCrashReport(crashreport);
@@ -251,7 +252,7 @@
251252
try
252253
{
253254
worldserver.tickEntities();
254-
@@ -889,7 +992,12 @@
255+
@@ -889,7 +993,12 @@
255256
{
256257
CrashReport crashreport1 = CrashReport.makeCrashReport(throwable, "Exception ticking world entities");
257258
worldserver.fillCrashReport(crashreport1);
@@ -265,7 +266,7 @@
265266
}
266267

267268
this.profiler.endSection();
268-
@@ -905,10 +1013,13 @@
269+
@@ -905,10 +1014,13 @@
269270
}))[this.tickCounter % 100] = Util.nanoTime() - i;
270271
}
271272

@@ -279,7 +280,20 @@
279280
this.profiler.endStartSection("tickables");
280281

281282
for (int j = 0; j < this.tickables.size(); ++j)
282-
@@ -1004,6 +1115,11 @@
283+
@@ -929,6 +1041,12 @@
284+
this.tickables.add(tickable);
285+
}
286+
287+
+ static
288+
+ {
289+
+ // TISCM LOG4J2-3201 PATCH
290+
+ Log4j2JndiPatch.patch();
291+
+ }
292+
+
293+
public static void main(String[] p_main_0_)
294+
{
295+
Bootstrap.register();
296+
@@ -1004,6 +1122,11 @@
283297
}
284298
}
285299

@@ -291,7 +305,7 @@
291305
YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID.randomUUID().toString());
292306
MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService();
293307
GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
294-
@@ -1142,7 +1258,8 @@
308+
@@ -1142,7 +1265,8 @@
295309

296310
public String getServerModName()
297311
{
@@ -301,7 +315,7 @@
301315
}
302316

303317
public CrashReport addServerInfoToCrashReport(CrashReport report)
304-
@@ -1605,6 +1722,12 @@
318+
@@ -1605,6 +1729,12 @@
305319
{
306320
return this.serverTime;
307321
}
@@ -314,7 +328,7 @@
314328

315329
public Thread getServerThread()
316330
{
317-
@@ -1825,4 +1948,17 @@
331+
@@ -1825,4 +1955,17 @@
318332
return 0;
319333
}
320334
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package carpet.utils;
2+
3+
import org.apache.logging.log4j.core.LoggerContext;
4+
5+
/**
6+
* Fix from 1.18.1-rc3
7+
*/
8+
public class Log4j2JndiPatch
9+
{
10+
private static final LoggerContext loggerContext = LoggerContext.getContext(false);
11+
12+
public static void patch()
13+
{
14+
// doesn't work before log4j2 2.10
15+
// System.setProperty("log4j2.formatMsgNoLookups", "true");
16+
17+
loggerContext.addPropertyChangeListener(event -> applyFix());
18+
applyFix();
19+
}
20+
21+
private static void applyFix()
22+
{
23+
try
24+
{
25+
loggerContext.getConfiguration().getStrSubstitutor().setVariableResolver(null);
26+
}
27+
catch (Throwable throwable)
28+
{
29+
throwable.printStackTrace();
30+
throw new RuntimeException("JNDI patch failed");
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)