Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update fuzz target source file path and binary name (#753)
`nss` failed FI build, found the new pair by improving the script in #752: ```bash #!/usr/bin/env bash PREFIX="OFG_UNIQUE_PREFIX_" # Find all source files containing 'LLVMFuzzerTestOneInput' and exclude specific paths FILES=$(find /src \ -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.cxx' \) \ -not -path '*/aflplusplus/*' \ -not -path '*/fuzztest/*' \ -not -path '*/honggfuzz/*' \ -not -path '*/libfuzzer/*' \ -exec grep -l 'LLVMFuzzerTestOneInput' {} \;) count=1 for file in $FILES; do echo "Inserting into $file" # Detect whether the file is C or C++ based on its extension if [[ "$file" == *.c ]]; then # Code for C files if ! grep -q "build_id_$count" "$file"; then cat <<EOF >>"$file" #include <stdio.h> const char build_id_$count[] __attribute__((used)) = "$PREFIX$file"; __attribute__((constructor)) static void reference_build_id_$count(void) { fprintf(stderr, "%s\\n", build_id_$count); } EOF fi else # Code for C++ files if ! grep -q "struct OFGBuildIdReference" "$file"; then cat <<EOF >>"$file" #include <cstdio> const char build_id_$count[] __attribute__((used)) = "$PREFIX$file"; struct OFGBuildIdReference { ~OFGBuildIdReference() { fprintf(stderr, "%s\\n", build_id_$count); } }; static OFGBuildIdReference ref; EOF fi fi count=$((count+1)) done echo "Unique build_id lines inserted in all matched files." ``` ```bash #!/usr/bin/env bash PREFIX="OFG_UNIQUE_PREFIX_" for bin in /out/*; do [ -f "$bin" -a -x "$bin" ] || continue binary_name=$(basename "$bin") # Extract lines containing PREFIX, remove prefix, then check each filepath while IFS= read -r filepath; do [ -z "$filepath" ] && continue if [ -f "$filepath" ]; then export TARGET_NAME="$binary_name" TARGET_PATH="$filepath" echo "Binary: $TARGET_NAME" echo "Source file: $TARGET_PATH" echo else echo "Binary: $binary_name" echo "Source file (not found): $filepath" echo fi done < <(strings "$bin" | grep "$PREFIX" | sed "s/^$PREFIX//") done ```
- Loading branch information