diff options
author | Khaled Yakdan <yakdan@code-intelligence.com> | 2022-02-28 21:07:41 +0100 |
---|---|---|
committer | Norbert Schneider <mail@bertschneider.de> | 2022-04-08 17:31:35 +0200 |
commit | 099ce0549f5e87dfa702bcbfb44dc5df49e116e9 (patch) | |
tree | 2fce93328493016c8ebd547c5015abf04bf28c87 /agent | |
parent | f22f61b3ac3b19ef4671a6cd7870f7a17af2c478 (diff) | |
download | jazzer-api-099ce0549f5e87dfa702bcbfb44dc5df49e116e9.tar.gz |
Add hooks for loading arbitrary libraries
We also add a test that checks having multiple BEFORE hooks for the
`java.lang.System.loadLibrary()` method since it is used in the builtin
native hooks
Diffstat (limited to 'agent')
-rw-r--r-- | agent/src/main/java/com/code_intelligence/jazzer/instrumentor/HookMethodVisitor.kt | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/agent/src/main/java/com/code_intelligence/jazzer/instrumentor/HookMethodVisitor.kt b/agent/src/main/java/com/code_intelligence/jazzer/instrumentor/HookMethodVisitor.kt index 64b96e03..1694be58 100644 --- a/agent/src/main/java/com/code_intelligence/jazzer/instrumentor/HookMethodVisitor.kt +++ b/agent/src/main/java/com/code_intelligence/jazzer/instrumentor/HookMethodVisitor.kt @@ -277,15 +277,17 @@ private class HookMethodVisitor( val withDescriptorKey = "$withoutDescriptorKey#$descriptor" hooks[withDescriptorKey].orEmpty() + hooks[withoutDescriptorKey].orEmpty() }.sortedBy { it.hookType } + val replaceHookCount = result.count { it.hookType == HookType.REPLACE } check( - result.isEmpty() || - result.count { it.hookType != HookType.REPLACE } == result.size || - result.count { it.hookType == HookType.REPLACE } == 1 + replaceHookCount == 0 || + (replaceHookCount == 1 && result.size == 1) ) { "For a given method, You can either have a single REPLACE hook or BEFORE/AFTER hooks. Found:\n $result" } - return result.filter { !isReplaceHookInJava6mode(it) } + return result + .filter { !isReplaceHookInJava6mode(it) } + .sortedByDescending { it.toString() } } private fun isReplaceHookInJava6mode(hook: Hook): Boolean { |