Skip to content

Commit

Permalink
[libfuzzer] Calculate deadline before setting timeout
Browse files Browse the repository at this point in the history
Previously we were calculating deadline and then calling fuzzfetch and
other setup steps, which can take a variable amount of time.
  • Loading branch information
jschwartzentruber committed Oct 7, 2024
1 parent df4aa98 commit 0b47cd8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions services/libfuzzer/libfuzzer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ then
setup-aws-credentials
fi

get-target-time () {
if [[ -n "$TASK_ID" ]] || [[ -n "$RUN_ID" ]]
then
TARGET_TIME="$(($(get-deadline) - $(date +%s) - 5 * 60))"
echo $(($(get-deadline) - $(date +%s) - 5 * 60))
else
TARGET_TIME=$((10 * 365 * 24 * 3600))
echo $((10 * 365 * 24 * 3600))
fi
}

mkdir -p ~/.ssh
if [[ ! -e ~/.ssh/id_rsa.fuzzing-shells-private ]] && [[ -z "$NO_SECRETS" ]]
Expand Down Expand Up @@ -160,9 +162,9 @@ FUZZDATA_URL="https://github.com/mozillasecurity/fuzzdata.git/trunk"
function run-afl-libfuzzer-daemon () {
if [[ -n "$XPCRT" ]]
then
xvfb-run timeout --foreground -s 2 ${TARGET_TIME} guided-fuzzing-daemon "$@" || [[ $? -eq 124 ]]
xvfb-run timeout --foreground -s 2 "$(get-target-time)" guided-fuzzing-daemon "$@" || [[ $? -eq 124 ]]
else
timeout --foreground -s 2 ${TARGET_TIME} guided-fuzzing-daemon "$@" || [[ $? -eq 124 ]]
timeout --foreground -s 2 "$(get-target-time)" guided-fuzzing-daemon "$@" || [[ $? -eq 124 ]]
fi

}
Expand Down

0 comments on commit 0b47cd8

Please sign in to comment.