MCPcopy Create free account
hub / github.com/burpheart/CVE-2022-39197-patch / transform

Method transform

src/main/java/org/patch/Swinghtml.java:14–31  ·  view source on GitHub ↗
(ClassLoader loader, String className, Class<?> classBeingRedefined,
                            ProtectionDomain protectionDomain, byte[] classfileBuffer)

Source from the content-addressed store, hash-verified

12
13public class Swinghtml implements ClassFileTransformer {
14 public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
15 ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
16 if(className.equals("javax/swing/plaf/basic/BasicHTML")){
17 try {
18 ClassPool classPool = ClassPool.getDefault();
19 classPool.appendClassPath(new LoaderClassPath(loader));
20 CtClass clazz = classPool.makeClass(new ByteArrayInputStream(classfileBuffer), false);
21 CtMethod method = clazz.getDeclaredMethod("isHTMLString");
22 method.setBody("return false;");
23 System.out.println("Successfully Patched.");
24 return clazz.toBytecode();
25 } catch (Exception e) {
26 e.printStackTrace();
27 System.out.println("Patch Failed.");
28 }
29 }
30 return null;
31 }
32}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected