Skip to content

Commit

Permalink
* Refactored
Browse files Browse the repository at this point in the history
* Fixed missing mask from SunUnsafeMasker
  • Loading branch information
katherine-hough committed Nov 29, 2023
1 parent 3919742 commit efd20e6
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 238 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ public static InstrumentationAdaptor getInstrumentation() {
}

@InvokedViaInstrumentation(record = TaintMethodRecord.INSTRUMENT_CLASS_BYTES)
public static byte[] instrumentClassBytes(byte[] in) {
return new PCLoggingTransformer().transform(null, null, null, null, in, false);
public static byte[] instrumentClassBytes(byte[] classFileBuffer) {
byte[] result = new PCLoggingTransformer().transform(null, null, null, null, classFileBuffer, false);
return result == null ? classFileBuffer : result;
}

@InvokedViaInstrumentation(record = TaintMethodRecord.INSTRUMENT_CLASS_BYTES_ANONYMOUS)
public static byte[] instrumentClassBytesAnonymous(byte[] in) {
return new PCLoggingTransformer().transform(null, null, null, null, in, true);
public static byte[] instrumentClassBytesAnonymous(byte[] classFileBuffer) {
byte[] result = new PCLoggingTransformer().transform(null, null, null, null, classFileBuffer, true);
return result == null ? classFileBuffer : result;
}

private static String[] parseOptions(String agentArgs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public long getInvalidFieldOffset() {
return Unsafe.INVALID_FIELD_OFFSET;
}

@Override
public Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches) {
return unsafe.defineAnonymousClass(hostClass, data, cpPatches);
}

@Override
public Class<?> defineClass(
String name, byte[] b, int off, int len, ClassLoader loader, ProtectionDomain protectionDomain) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ private static Class<?> defineClass(
return null;
}

@Override
public Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches) {
return unsafe.defineAnonymousClass(hostClass, data, cpPatches);
}

@Override
public Class<?> defineClass(
String name, byte[] b, int off, int len, ClassLoader loader, ProtectionDomain protectionDomain) {
Expand Down
Loading

0 comments on commit efd20e6

Please sign in to comment.