From 9107b16b9ec05ba9c4f4ec047bd335639099126d Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Tue, 5 Apr 2022 10:46:26 +0200 Subject: Add the agent to the classpath with --nohooks Fixes https://github.com/google/oss-fuzz/issues/7507 --- driver/jvm_tooling.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'driver/jvm_tooling.cpp') diff --git a/driver/jvm_tooling.cpp b/driver/jvm_tooling.cpp index 688d7c4a..35bd8bad 100644 --- a/driver/jvm_tooling.cpp +++ b/driver/jvm_tooling.cpp @@ -238,7 +238,14 @@ JVM::JVM(std::string_view executable_path, std::string_view seed) { std::string class_path = absl::StrFormat("-Djava.class.path=%s", FLAGS_cp); const auto class_path_from_env = std::getenv("JAVA_FUZZER_CLASSPATH"); if (class_path_from_env) { - class_path += absl::StrFormat(ARG_SEPARATOR "%s", class_path_from_env); + class_path += absl::StrCat(ARG_SEPARATOR, class_path_from_env); + } + if (!FLAGS_hooks) { + // A Java agent is implicitly added to the system class loader's classpath, + // so there is no need to add the Jazzer agent here if we are running with + // the agent enabled. + class_path += + absl::StrCat(ARG_SEPARATOR, getInstrumentorAgentPath(executable_path)); } LOG(INFO) << "got class path " << class_path; -- cgit v1.2.3