|
| 1 | +#!/bin/bash -eu |
| 2 | +# Copyright 2025 Google LLC |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | +################################################################################ |
| 17 | + |
| 18 | +# This script is useful for OSS-Fuzz infrastructure which is used to rebuild |
| 19 | +# code from cached images. This is to support various ongoing efforts in |
| 20 | +# OSS-Fuzz. |
| 21 | + |
| 22 | +# List of targets disabled for oss-fuzz. |
| 23 | +declare -A disabled=() |
| 24 | +# List of targets we want to fuzz in TLS and non-TLS mode. |
| 25 | +declare -A tls_targets=([tls-client]=1 [tls-server]=1 [dtls-client]=1 [dtls-server]=1) |
| 26 | +# Helper function that copies a fuzzer binary and its seed corpus. |
| 27 | +copy_fuzzer() |
| 28 | +{ |
| 29 | + local fuzzer=$1 |
| 30 | + local name=$2 |
| 31 | + # Copy the binary. |
| 32 | + cp ../dist/Debug/bin/$fuzzer $OUT/$name |
| 33 | +} |
| 34 | + |
| 35 | +# Modify the harness to make sure we recompile |
| 36 | +ninja -C /src/nss/out/Debug -v |
| 37 | + |
| 38 | +# Build the library only in TLS fuzzing mode. |
| 39 | +cd $SRC/nss |
| 40 | + |
| 41 | +# Copy dual mode targets in TLS mode. |
| 42 | +for name in "${!tls_targets[@]}"; do |
| 43 | + if [ -z "${disabled[$name]:-}" ]; then |
| 44 | + copy_fuzzer nssfuzz-$name $name |
| 45 | + fi |
| 46 | +done |
0 commit comments