[json-sanitizer][jazzer] Don't assume that fuzzer is run from its directory (#5217)

This is a speculative fix for an issue we've seen where the class
fails to load.
A simpler approach I did not use is cd-ing into $this_dir. I didn't
use this approach because it will break things if relative paths
are passed to the fuzzer by ClusterFuzz.

The other reason that I think could be responsible for the missing
class issues is not unpacking the zipfile fully.
This commit is contained in:
jonathanmetzman 2021-02-18 08:25:21 -08:00 committed by GitHub
parent fa46369f1e
commit 346370af46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -36,7 +36,7 @@ ALL_JARS="$PROJECT_JARS $FUZZER_JARS"
BUILD_CLASSPATH=$(echo $ALL_JARS | xargs printf -- "$OUT/%s:"):$JAZZER_API_PATH BUILD_CLASSPATH=$(echo $ALL_JARS | xargs printf -- "$OUT/%s:"):$JAZZER_API_PATH
# All jars and class files lie in the same directory as the fuzzer at runtime. # All jars and class files lie in the same directory as the fuzzer at runtime.
RUNTIME_CLASSPATH=$(echo $ALL_JARS | xargs printf -- "%s:"):. RUNTIME_CLASSPATH=$(echo $ALL_JARS | xargs printf -- "\$this_dir/%s:"):.:\$this_dir
for fuzzer in $(find $SRC -name '*Fuzzer.java'); do for fuzzer in $(find $SRC -name '*Fuzzer.java'); do
fuzzer_basename=$(basename -s .java $fuzzer) fuzzer_basename=$(basename -s .java $fuzzer)
@ -49,9 +49,9 @@ for fuzzer in $(find $SRC -name '*Fuzzer.java'); do
this_dir=\$(dirname \"\$0\") this_dir=\$(dirname \"\$0\")
LD_LIBRARY_PATH=\"$JVM_LD_LIBRARY_PATH\" \ LD_LIBRARY_PATH=\"$JVM_LD_LIBRARY_PATH\" \
\$this_dir/jazzer_driver --agent_path=\$this_dir/jazzer_agent_deploy.jar \ \$this_dir/jazzer_driver --agent_path=\$this_dir/jazzer_agent_deploy.jar \
--cp=$RUNTIME_CLASSPATH \ --cp=$RUNTIME_CLASSPATH \
--target_class=$fuzzer_basename \ --target_class=$fuzzer_basename \
--jvm_args=\"-Xmx2048m\" \ --jvm_args=\"-Xmx2048m\" \
\$@" > $OUT/$fuzzer_basename \$@" > $OUT/$fuzzer_basename
chmod u+x $OUT/$fuzzer_basename chmod u+x $OUT/$fuzzer_basename
done done