U20: ec-image fuzz reduced to 3 targets (decode, decode_animation, probe; per-format targets are covered by decode); seed.sh follows
Browse files at this commit63cd8d5389f46b0454b756369bf7c7826944db99Parent: 18956d710 changed files +13 -226
- crates/ec-image/fuzz/Cargo.toml +0 -56
- crates/ec-image/fuzz/fuzz_targets/bmp.rs +0 -17
- crates/ec-image/fuzz/fuzz_targets/decode_with_limits.rs +0 -17
- crates/ec-image/fuzz/fuzz_targets/gif.rs +0 -18
- crates/ec-image/fuzz/fuzz_targets/info.rs +0 -8
- crates/ec-image/fuzz/fuzz_targets/jpeg.rs +0 -18
- crates/ec-image/fuzz/fuzz_targets/png.rs +0 -17
- crates/ec-image/fuzz/fuzz_targets/tiff.rs +0 -17
- crates/ec-image/fuzz/fuzz_targets/webp.rs +0 -18
- crates/ec-image/fuzz/seed.sh +13 -40
crates/ec-image/fuzz/Cargo.tomlmodified+0 -56
| @@ -24,20 +24,6 @@ test = false | |||
| 24 | doc = false | 24 | doc = false |
| 25 | bench = false | 25 | bench = false |
| 26 | 26 | ||
| 27 | -[[bin]] | ||
| 28 | -name = "decode_with_limits" | ||
| 29 | -path = "fuzz_targets/decode_with_limits.rs" | ||
| 30 | -test = false | ||
| 31 | -doc = false | ||
| 32 | -bench = false | ||
| 33 | - | ||
| 34 | -[[bin]] | ||
| 35 | -name = "info" | ||
| 36 | -path = "fuzz_targets/info.rs" | ||
| 37 | -test = false | ||
| 38 | -doc = false | ||
| 39 | -bench = false | ||
| 40 | - | ||
| 41 | [[bin]] | 27 | [[bin]] |
| 42 | name = "decode_animation" | 28 | name = "decode_animation" |
| 43 | path = "fuzz_targets/decode_animation.rs" | 29 | path = "fuzz_targets/decode_animation.rs" |
| @@ -45,48 +31,6 @@ test = false | |||
| 45 | doc = false | 31 | doc = false |
| 46 | bench = false | 32 | bench = false |
| 47 | 33 | ||
| 48 | -[[bin]] | ||
| 49 | -name = "bmp" | ||
| 50 | -path = "fuzz_targets/bmp.rs" | ||
| 51 | -test = false | ||
| 52 | -doc = false | ||
| 53 | -bench = false | ||
| 54 | - | ||
| 55 | -[[bin]] | ||
| 56 | -name = "gif" | ||
| 57 | -path = "fuzz_targets/gif.rs" | ||
| 58 | -test = false | ||
| 59 | -doc = false | ||
| 60 | -bench = false | ||
| 61 | - | ||
| 62 | -[[bin]] | ||
| 63 | -name = "jpeg" | ||
| 64 | -path = "fuzz_targets/jpeg.rs" | ||
| 65 | -test = false | ||
| 66 | -doc = false | ||
| 67 | -bench = false | ||
| 68 | - | ||
| 69 | -[[bin]] | ||
| 70 | -name = "png" | ||
| 71 | -path = "fuzz_targets/png.rs" | ||
| 72 | -test = false | ||
| 73 | -doc = false | ||
| 74 | -bench = false | ||
| 75 | - | ||
| 76 | -[[bin]] | ||
| 77 | -name = "tiff" | ||
| 78 | -path = "fuzz_targets/tiff.rs" | ||
| 79 | -test = false | ||
| 80 | -doc = false | ||
| 81 | -bench = false | ||
| 82 | - | ||
| 83 | -[[bin]] | ||
| 84 | -name = "webp" | ||
| 85 | -path = "fuzz_targets/webp.rs" | ||
| 86 | -test = false | ||
| 87 | -doc = false | ||
| 88 | -bench = false | ||
| 89 | - | ||
| 90 | [[bin]] | 34 | [[bin]] |
| 91 | name = "probe" | 35 | name = "probe" |
| 92 | path = "fuzz_targets/probe.rs" | 36 | path = "fuzz_targets/probe.rs" |
crates/ec-image/fuzz/fuzz_targets/bmp.rsdeleted+0 -17
| @@ -1,17 +0,0 @@ | |||
| 1 | -#![no_main] | ||
| 2 | - | ||
| 3 | -use ec_image::Limits; | ||
| 4 | -use libfuzzer_sys::fuzz_target; | ||
| 5 | - | ||
| 6 | -// The bmp module's own entry points, called directly so the format signature check in the | ||
| 7 | -// dispatcher does not filter the input first. Header parse, then a decode under small limits. | ||
| 8 | -const LIMITS: Limits = Limits { | ||
| 9 | - max_pixels: 4096 * 4096, | ||
| 10 | - max_alloc: 1 << 26, | ||
| 11 | - max_total_alloc: 1 << 27, | ||
| 12 | -}; | ||
| 13 | - | ||
| 14 | -fuzz_target!(|data: &[u8]| { | ||
| 15 | - let _ = ec_image::bmp::info(data); | ||
| 16 | - let _ = ec_image::bmp::decode(data, LIMITS); | ||
| 17 | -}); | ||
crates/ec-image/fuzz/fuzz_targets/decode_with_limits.rsdeleted+0 -17
| @@ -1,17 +0,0 @@ | |||
| 1 | -#![no_main] | ||
| 2 | - | ||
| 3 | -use ec_image::Limits; | ||
| 4 | -use libfuzzer_sys::fuzz_target; | ||
| 5 | - | ||
| 6 | -// Small limits: 4096x4096 pixels, 64 MiB per buffer, 128 MiB across one call. Under these a | ||
| 7 | -// hostile header is refused before it sizes anything, and every path that multiplies a count by | ||
| 8 | -// a size still gets exercised against a real budget. | ||
| 9 | -const LIMITS: Limits = Limits { | ||
| 10 | - max_pixels: 4096 * 4096, | ||
| 11 | - max_alloc: 1 << 26, | ||
| 12 | - max_total_alloc: 1 << 27, | ||
| 13 | -}; | ||
| 14 | - | ||
| 15 | -fuzz_target!(|data: &[u8]| { | ||
| 16 | - let _ = ec_image::decode_with_limits(data, LIMITS); | ||
| 17 | -}); | ||
crates/ec-image/fuzz/fuzz_targets/gif.rsdeleted+0 -18
| @@ -1,18 +0,0 @@ | |||
| 1 | -#![no_main] | ||
| 2 | - | ||
| 3 | -use ec_image::Limits; | ||
| 4 | -use libfuzzer_sys::fuzz_target; | ||
| 5 | - | ||
| 6 | -// The gif module's own entry points, called directly so the format signature check in the | ||
| 7 | -// dispatcher does not filter the input first. Header parse, then a decode under small limits. | ||
| 8 | -const LIMITS: Limits = Limits { | ||
| 9 | - max_pixels: 4096 * 4096, | ||
| 10 | - max_alloc: 1 << 26, | ||
| 11 | - max_total_alloc: 1 << 27, | ||
| 12 | -}; | ||
| 13 | - | ||
| 14 | -fuzz_target!(|data: &[u8]| { | ||
| 15 | - let _ = ec_image::gif::info(data); | ||
| 16 | - let _ = ec_image::gif::decode(data, LIMITS); | ||
| 17 | - let _ = ec_image::gif::decode_animation(data, LIMITS); | ||
| 18 | -}); | ||
crates/ec-image/fuzz/fuzz_targets/info.rsdeleted+0 -8
| @@ -1,8 +0,0 @@ | |||
| 1 | -#![no_main] | ||
| 2 | - | ||
| 3 | -use libfuzzer_sys::fuzz_target; | ||
| 4 | - | ||
| 5 | -// Header-only parse: dimensions and format details without decoding any pixels. | ||
| 6 | -fuzz_target!(|data: &[u8]| { | ||
| 7 | - let _ = ec_image::info(data); | ||
| 8 | -}); | ||
crates/ec-image/fuzz/fuzz_targets/jpeg.rsdeleted+0 -18
| @@ -1,18 +0,0 @@ | |||
| 1 | -#![no_main] | ||
| 2 | - | ||
| 3 | -use ec_image::Limits; | ||
| 4 | -use libfuzzer_sys::fuzz_target; | ||
| 5 | - | ||
| 6 | -// The jpeg module's own entry points, called directly so the format signature check in the | ||
| 7 | -// dispatcher does not filter the input first. Header parse, then a decode under small limits. | ||
| 8 | -const LIMITS: Limits = Limits { | ||
| 9 | - max_pixels: 4096 * 4096, | ||
| 10 | - max_alloc: 1 << 26, | ||
| 11 | - max_total_alloc: 1 << 27, | ||
| 12 | -}; | ||
| 13 | - | ||
| 14 | -fuzz_target!(|data: &[u8]| { | ||
| 15 | - let _ = ec_image::jpeg::info(data); | ||
| 16 | - let _ = ec_image::jpeg::decode(data, LIMITS); | ||
| 17 | - let _ = ec_image::jpeg::decode_yuv(data, LIMITS); | ||
| 18 | -}); | ||
crates/ec-image/fuzz/fuzz_targets/png.rsdeleted+0 -17
| @@ -1,17 +0,0 @@ | |||
| 1 | -#![no_main] | ||
| 2 | - | ||
| 3 | -use ec_image::Limits; | ||
| 4 | -use libfuzzer_sys::fuzz_target; | ||
| 5 | - | ||
| 6 | -// The png module's own entry points, called directly so the format signature check in the | ||
| 7 | -// dispatcher does not filter the input first. Header parse, then a decode under small limits. | ||
| 8 | -const LIMITS: Limits = Limits { | ||
| 9 | - max_pixels: 4096 * 4096, | ||
| 10 | - max_alloc: 1 << 26, | ||
| 11 | - max_total_alloc: 1 << 27, | ||
| 12 | -}; | ||
| 13 | - | ||
| 14 | -fuzz_target!(|data: &[u8]| { | ||
| 15 | - let _ = ec_image::png::info(data); | ||
| 16 | - let _ = ec_image::png::decode(data, LIMITS); | ||
| 17 | -}); | ||
crates/ec-image/fuzz/fuzz_targets/tiff.rsdeleted+0 -17
| @@ -1,17 +0,0 @@ | |||
| 1 | -#![no_main] | ||
| 2 | - | ||
| 3 | -use ec_image::Limits; | ||
| 4 | -use libfuzzer_sys::fuzz_target; | ||
| 5 | - | ||
| 6 | -// The tiff module's own entry points, called directly so the format signature check in the | ||
| 7 | -// dispatcher does not filter the input first. Header parse, then a decode under small limits. | ||
| 8 | -const LIMITS: Limits = Limits { | ||
| 9 | - max_pixels: 4096 * 4096, | ||
| 10 | - max_alloc: 1 << 26, | ||
| 11 | - max_total_alloc: 1 << 27, | ||
| 12 | -}; | ||
| 13 | - | ||
| 14 | -fuzz_target!(|data: &[u8]| { | ||
| 15 | - let _ = ec_image::tiff::info(data); | ||
| 16 | - let _ = ec_image::tiff::decode(data, LIMITS); | ||
| 17 | -}); | ||
crates/ec-image/fuzz/fuzz_targets/webp.rsdeleted+0 -18
| @@ -1,18 +0,0 @@ | |||
| 1 | -#![no_main] | ||
| 2 | - | ||
| 3 | -use ec_image::Limits; | ||
| 4 | -use libfuzzer_sys::fuzz_target; | ||
| 5 | - | ||
| 6 | -// The webp module's own entry points, called directly so the format signature check in the | ||
| 7 | -// dispatcher does not filter the input first. Header parse, then a decode under small limits. | ||
| 8 | -const LIMITS: Limits = Limits { | ||
| 9 | - max_pixels: 4096 * 4096, | ||
| 10 | - max_alloc: 1 << 26, | ||
| 11 | - max_total_alloc: 1 << 27, | ||
| 12 | -}; | ||
| 13 | - | ||
| 14 | -fuzz_target!(|data: &[u8]| { | ||
| 15 | - let _ = ec_image::webp::info(data); | ||
| 16 | - let _ = ec_image::webp::decode(data, LIMITS); | ||
| 17 | - let _ = ec_image::webp::decode_frames(data, LIMITS); | ||
| 18 | -}); | ||
crates/ec-image/fuzz/seed.shmodified+13 -40
| @@ -1,11 +1,7 @@ | |||
| 1 | #!/usr/bin/env bash | 1 | #!/usr/bin/env bash |
| 2 | # seed.sh: fill fuzz/corpus/<target>/ from the repo's still-image fixtures. | 2 | # seed.sh: fill fuzz/corpus/<target>/ from the repo's still-image fixtures. |
| 3 | # | 3 | # |
| 4 | -# Every file under tests/data/stills (PNG, JPEG, WebP, GIF, BMP, TIFF) seeds the whole-file targets: | 4 | +# Every file under tests/data/stills seeds each whole-file target: decode, decode_animation, probe. |
| 5 | -# decode, decode_with_limits, info, probe, decode_animation. Each format target gets only the files of its | ||
| 6 | -# own format, so its corpus starts on the right signature. The VP8 frames under fixtures/vp8 are | ||
| 7 | -# VP8 bitstreams, not stills, and are not used here. | ||
| 8 | -# | ||
| 9 | # Corpus lives under fuzz/corpus, which is git-ignored. | 5 | # Corpus lives under fuzz/corpus, which is git-ignored. |
| 10 | set -euo pipefail | 6 | set -euo pipefail |
| 11 | 7 | ||
| @@ -14,39 +10,16 @@ STILLS="$FUZZ_DIR/../tests/data/stills" | |||
| 14 | [ -d "$STILLS" ] || { echo "seed.sh: $STILLS missing" >&2; exit 2; } | 10 | [ -d "$STILLS" ] || { echo "seed.sh: $STILLS missing" >&2; exit 2; } |
| 15 | 11 | ||
| 16 | CORPUS="$FUZZ_DIR/corpus" | 12 | CORPUS="$FUZZ_DIR/corpus" |
| 17 | -mkdir -p "$CORPUS"/{decode,decode_with_limits,info,probe,decode_animation,bmp,gif,jpeg,png,tiff,webp} | 13 | +TARGETS=(decode decode_animation probe) |
| 18 | - | 14 | +mkdir -p "${TARGETS[@]/#/$CORPUS/}" |
| 19 | -python3 -I - "$STILLS" "$CORPUS" <<'PY' | ||
| 20 | -import glob, os, sys | ||
| 21 | - | ||
| 22 | -stills, corpus = sys.argv[1], sys.argv[2] | ||
| 23 | -by_format = { | ||
| 24 | - "png": (".png",), "jpeg": (".jpg", ".jpeg"), "webp": (".webp",), | ||
| 25 | - "gif": (".gif",), "bmp": (".bmp",), "tiff": (".tif", ".tiff"), | ||
| 26 | -} | ||
| 27 | -all_files = sorted(p for p in glob.glob(os.path.join(stills, "*")) if os.path.isfile(p)) | ||
| 28 | -if not all_files: | ||
| 29 | - sys.exit("seed.sh: no still-image fixtures found") | ||
| 30 | - | ||
| 31 | -def write(target, name, data): | ||
| 32 | - with open(os.path.join(corpus, target, name), "wb") as f: | ||
| 33 | - f.write(data) | ||
| 34 | - | ||
| 35 | -count = {} | ||
| 36 | -def bump(t): | ||
| 37 | - count[t] = count.get(t, 0) + 1 | ||
| 38 | 15 | ||
| 39 | -for path in all_files: | 16 | +n=0 |
| 40 | - name = os.path.basename(path) | 17 | +for path in "$STILLS"/*; do |
| 41 | - ext = os.path.splitext(name)[1].lower() | 18 | + [ -f "$path" ] || continue |
| 42 | - data = open(path, "rb").read() | 19 | + for t in "${TARGETS[@]}"; do |
| 43 | - for t in ("decode", "decode_with_limits", "info", "probe", "decode_animation"): | 20 | + cp "$path" "$CORPUS/$t/$(basename "$path")" |
| 44 | - write(t, name, data) | 21 | + n=$((n + 1)) |
| 45 | - bump(t) | 22 | + done |
| 46 | - for fmt, exts in by_format.items(): | 23 | +done |
| 47 | - if ext in exts: | 24 | +[ "$n" -gt 0 ] || { echo "seed.sh: no still-image fixtures found" >&2; exit 2; } |
| 48 | - write(fmt, name, data) | 25 | +echo "seeded $n files under $CORPUS" |
| 49 | - bump(fmt) | ||
| 50 | -for t in ("decode", "decode_with_limits", "info", "decode_animation", "bmp", "gif", "jpeg", "png", "tiff", "webp"): | ||
| 51 | - print(f"{t}: {count.get(t, 0)} seeds") | ||
| 52 | -PY | ||