From 3ade60d0b429e89e6d2cc2c8d3efea6d6ec72005 Mon Sep 17 00:00:00 2001 From: mnovak Date: Wed, 25 Nov 2026 12:01:09 +0100 Subject: [PATCH] [repo] Fuzz: one libFuzzer target per parser, own workspace, Windows MSVC setup from Via --- fuzz/Cargo.lock | 633 +++++++++++++++++++++++++++ fuzz/Cargo.toml | 155 +++++++ fuzz/build.rs | 7 + fuzz/fuzz_targets/app_list.rs | 11 + fuzz/fuzz_targets/audio_packet.rs | 11 + fuzz/fuzz_targets/control_frame.rs | 11 + fuzz/fuzz_targets/control_message.rs | 11 + fuzz/fuzz_targets/enet_datagram.rs | 11 + fuzz/fuzz_targets/input.rs | 11 + fuzz/fuzz_targets/launch_response.rs | 11 + fuzz/fuzz_targets/pair_response.rs | 11 + fuzz/fuzz_targets/rtp_header.rs | 11 + fuzz/fuzz_targets/rtsp_framer.rs | 23 + fuzz/fuzz_targets/rtsp_request.rs | 11 + fuzz/fuzz_targets/rtsp_response.rs | 11 + fuzz/fuzz_targets/sdp.rs | 13 + fuzz/fuzz_targets/server_cert_pem.rs | 11 + fuzz/fuzz_targets/server_info.rs | 11 + fuzz/fuzz_targets/video_packet.rs | 12 + fuzz/fuzz_targets/xml.rs | 11 + fuzz/win_sections.c | 9 + 21 files changed, 1006 insertions(+) create mode 100644 fuzz/Cargo.lock create mode 100644 fuzz/Cargo.toml create mode 100644 fuzz/build.rs create mode 100644 fuzz/fuzz_targets/app_list.rs create mode 100644 fuzz/fuzz_targets/audio_packet.rs create mode 100644 fuzz/fuzz_targets/control_frame.rs create mode 100644 fuzz/fuzz_targets/control_message.rs create mode 100644 fuzz/fuzz_targets/enet_datagram.rs create mode 100644 fuzz/fuzz_targets/input.rs create mode 100644 fuzz/fuzz_targets/launch_response.rs create mode 100644 fuzz/fuzz_targets/pair_response.rs create mode 100644 fuzz/fuzz_targets/rtp_header.rs create mode 100644 fuzz/fuzz_targets/rtsp_framer.rs create mode 100644 fuzz/fuzz_targets/rtsp_request.rs create mode 100644 fuzz/fuzz_targets/rtsp_response.rs create mode 100644 fuzz/fuzz_targets/sdp.rs create mode 100644 fuzz/fuzz_targets/server_cert_pem.rs create mode 100644 fuzz/fuzz_targets/server_info.rs create mode 100644 fuzz/fuzz_targets/video_packet.rs create mode 100644 fuzz/fuzz_targets/xml.rs create mode 100644 fuzz/win_sections.c diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock new file mode 100644 index 0000000..333faea --- /dev/null +++ b/fuzz/Cargo.lock @@ -0,0 +1,633 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aead" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1973cfbc1a2daf9cf550e74e1f088c28e7f7d8c1e1418fb6c9dc5184b7e84c99" +dependencies = [ + "crypto-common", + "inout", +] + +[[package]] +name = "aes" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fc36d7440d015b45468ba08a21e80e056ebbd014c611c6298bb7503e04bd1" +dependencies = [ + "cipher", + "cpubits", + "cpufeatures", +] + +[[package]] +name = "aes-gcm" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2b8006a0c83f52b62ba44a97b58bf76fe2f70a329e588f67f89691d93d498f" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "ctutils", + "ghash", +] + +[[package]] +name = "arbitrary" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bc62ac97cc33321f50863d514c3bc38a453947a8f9e781137e47c7401020aed" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "base16ct" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6" + +[[package]] +name = "base64ct" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" + +[[package]] +name = "block-buffer" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" +dependencies = [ + "hybrid-array", + "zeroize", +] + +[[package]] +name = "block-padding" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "710f1dd022ef4e93f8a438b4ba958de7f64308434fa6a87104481645cc30068b" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "cbc" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce2dc9ee5f88d11e0beb842c88b33c8a5cf0d1329c4b19494af42b07dbfe8896" +dependencies = [ + "cipher", +] + +[[package]] +name = "cc" +version = "1.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02f0e023adb368345ce0ca6cdfc0f24a06554468d0e8503e14a0841de79bfa69" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cipher" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" +dependencies = [ + "block-buffer", + "crypto-common", + "inout", +] + +[[package]] +name = "cmov" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" + +[[package]] +name = "const-oid" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" + +[[package]] +name = "cpubits" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" + +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-bigint" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914c195c4d7fbc5ed7f88d14cbf85914d5c664967658d43404b263913a477e82" +dependencies = [ + "cpubits", + "ctutils", + "getrandom", + "num-traits", + "rand_core", + "serdect", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" +dependencies = [ + "getrandom", + "hybrid-array", + "rand_core", +] + +[[package]] +name = "crypto-primes" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3633a51a39c69ebbaa4feaa694bd83d241e4093901c84a0963b19d9bb3f0cf8f" +dependencies = [ + "crypto-bigint", + "rand_core", +] + +[[package]] +name = "ctr" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baaca1c4b237092596f64d571e9db6ce4109c4ef9742e27590f1709594461f21" +dependencies = [ + "cipher", +] + +[[package]] +name = "ctutils" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261af4dc7a06ea8a527a8717d8cbba3417530d6ea14e1edb3de6b67806be474f" +dependencies = [ + "cmov", +] + +[[package]] +name = "der" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a996a108feb8b427a6e12fcf6af4aa83409b79d72c15337d7741368131ee004" +dependencies = [ + "const-oid", + "der_derive", + "flagset", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "der_derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59600e2c2d636fde9b65e99cc6445ac770c63d3628195ff39932b8d6d7409903" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "digest" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common", + "ctutils", + "zeroize", +] + +[[package]] +name = "domistream" +version = "0.1.0" +dependencies = [ + "aes", + "aes-gcm", + "cbc", + "rand_core", + "rsa", + "sha2", + "x509-cert", + "zeroize", +] + +[[package]] +name = "domistream-fuzz" +version = "0.0.0" +dependencies = [ + "cc", + "domistream", + "libfuzzer-sys", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + +[[package]] +name = "flagset" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7ac824320a75a52197e8f2d787f6a38b6718bb6897a35142d749af3c0e8f4fe" + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "rand_core", +] + +[[package]] +name = "ghash" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eecf2d5dc9b66b732b97707a0210906b1d30523eb773193ab777c0c84b3e8d5" +dependencies = [ + "polyval", +] + +[[package]] +name = "hmac" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" +dependencies = [ + "digest", +] + +[[package]] +name = "hybrid-array" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" +dependencies = [ + "typenum", +] + +[[package]] +name = "inout" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a580c13f0ffc335ef42dd3f6b1a41b726051c5e1656d9a3aa6fddb3c5dfbbf9" +dependencies = [ + "block-padding", + "hybrid-array", +] + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom", + "libc", +] + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libfuzzer-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9fd2f41a1cba099f79a0b6b6c35656cf7c03351a7bae8ff0f28f25270f929d2" +dependencies = [ + "arbitrary", + "cc", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "pem-rfc7468" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6305423e0e7738146434843d1694d621cce767262b2a86910beab705e4493d9" +dependencies = [ + "base64ct", +] + +[[package]] +name = "pkcs1" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6250dd7321adbe93d12b750aee0ced159fd13e77f625edcdf1cb6f83cd99f650" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "451913da69c775a56034ea8d9003d27ee8948e12443eae7c038ba100a4f21cb7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "polyval" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0fa31d631f2b2cb2a544d0aa321ce847a94764d701ca2becc411138b93d49cd" +dependencies = [ + "cpubits", + "cpufeatures", + "universal-hash", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "rsa" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e77fd77e0dea28b3011fd62d15445b7de7959333b0276d930e03be0f755699" +dependencies = [ + "const-oid", + "crypto-bigint", + "crypto-common", + "crypto-primes", + "digest", + "hmac", + "pkcs1", + "pkcs8", + "rand_core", + "sha2", + "signature", + "spki", + "zeroize", +] + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "serdect" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66cf8fedced2fcf12406bcb34223dffb92eaf34908ede12fed414c82b7f00b3e" +dependencies = [ + "base16ct", + "serde", +] + +[[package]] +name = "sha1" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signature" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5" +dependencies = [ + "digest", + "rand_core", +] + +[[package]] +name = "spki" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef958a98b9d5da290cfc78946e9f3e61e1e62a18db0d92cac0b83cc161491a9" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tls_codec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de2e01245e2bb89d6f05801c564fa27624dbd7b1846859876c7dad82e90bf6b" +dependencies = [ + "tls_codec_derive", + "zeroize", +] + +[[package]] +name = "tls_codec_derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2e76690929402faae40aebdda620a2c0e25dd6d3b9afe48867dfd95991f4bd" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "universal-hash" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96" +dependencies = [ + "crypto-common", + "ctutils", +] + +[[package]] +name = "x509-cert" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9f58ad685a2945c7c063f5d69b5c27105d75bb85c740380d8fc64e79a098417" +dependencies = [ + "const-oid", + "der", + "sha1", + "signature", + "spki", + "tls_codec", +] + +[[package]] +name = "zeroize" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ccff8a4805aba1eaa4cd4afcd49f7557dd2cf5fd79ffc37f8959466effc5aa" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml new file mode 100644 index 0000000..02a51df --- /dev/null +++ b/fuzz/Cargo.toml @@ -0,0 +1,155 @@ +# Fuzz targets: one per DomiStream parser. Its own workspace, built only for fuzzing, never released. +# +# Linux, nightly, cargo-fuzz: +# cargo fuzz run -- -max_total_time=600 +# +# Windows, stable MSVC, no cargo-fuzz, no sanitizer (same setup as Via's via-core/fuzz): build.rs + win_sections.c +# give SanitizerCoverage's counters their section bounds, so the targets link without a sanitizer runtime. +# cd fuzz +# RUSTFLAGS="-Cpasses=sancov-module -Cllvm-args=-sanitizer-coverage-level=4 +# -Cllvm-args=-sanitizer-coverage-inline-8bit-counters -Cllvm-args=-sanitizer-coverage-trace-compares +# -Cllvm-args=-simplifycfg-branch-fold-threshold=0 -Ccodegen-units=1 --cfg fuzzing -Cdebug-assertions +# -Clink-arg=/include:main" \ +# cargo build --release --target x86_64-pc-windows-msvc --bin +# target/x86_64-pc-windows-msvc/release/.exe -max_total_time=600 corpus/ +# corpus/ and artifacts/ stay out of git. Never set CARGO_TARGET_DIR. + +[package] +name = "domistream-fuzz" +version = "0.0.0" +edition = "2024" +publish = false +license = "CPAL-1.0" + +[package.metadata] +cargo-fuzz = true + +[build-dependencies] +cc = "1" + +[dependencies] +libfuzzer-sys = "0.4" +domistream = { path = "../crates/domistream" } + +# Its own workspace, so the fuzz build never joins the main one (cargo fuzz's layout). +[workspace] +members = ["."] + +[[bin]] +name = "xml" +path = "fuzz_targets/xml.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "server_info" +path = "fuzz_targets/server_info.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "app_list" +path = "fuzz_targets/app_list.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "launch_response" +path = "fuzz_targets/launch_response.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "pair_response" +path = "fuzz_targets/pair_response.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "server_cert_pem" +path = "fuzz_targets/server_cert_pem.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "rtsp_response" +path = "fuzz_targets/rtsp_response.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "rtsp_request" +path = "fuzz_targets/rtsp_request.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "sdp" +path = "fuzz_targets/sdp.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "rtsp_framer" +path = "fuzz_targets/rtsp_framer.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "enet_datagram" +path = "fuzz_targets/enet_datagram.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "control_frame" +path = "fuzz_targets/control_frame.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "control_message" +path = "fuzz_targets/control_message.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "input" +path = "fuzz_targets/input.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "rtp_header" +path = "fuzz_targets/rtp_header.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "video_packet" +path = "fuzz_targets/video_packet.rs" +test = false +doc = false +bench = false + +[[bin]] +name = "audio_packet" +path = "fuzz_targets/audio_packet.rs" +test = false +doc = false +bench = false diff --git a/fuzz/build.rs b/fuzz/build.rs new file mode 100644 index 0000000..7658367 --- /dev/null +++ b/fuzz/build.rs @@ -0,0 +1,7 @@ +// Windows only: give the coverage counters their section bounds (see win_sections.c). +fn main() { + println!("cargo:rerun-if-changed=win_sections.c"); + if std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc") { + cc::Build::new().file("win_sections.c").compile("win_sections"); + } +} diff --git a/fuzz/fuzz_targets/app_list.rs b/fuzz/fuzz_targets/app_list.rs new file mode 100644 index 0000000..559bcdb --- /dev/null +++ b/fuzz/fuzz_targets/app_list.rs @@ -0,0 +1,11 @@ +//! Fuzzes `/applist` answers: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::http::parse_app_list(data); +}); diff --git a/fuzz/fuzz_targets/audio_packet.rs b/fuzz/fuzz_targets/audio_packet.rs new file mode 100644 index 0000000..394184c --- /dev/null +++ b/fuzz/fuzz_targets/audio_packet.rs @@ -0,0 +1,11 @@ +//! Fuzzes audio packets: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::audio::parse_audio_packet(data); +}); diff --git a/fuzz/fuzz_targets/control_frame.rs b/fuzz/fuzz_targets/control_frame.rs new file mode 100644 index 0000000..0dde0cd --- /dev/null +++ b/fuzz/fuzz_targets/control_frame.rs @@ -0,0 +1,11 @@ +//! Fuzzes encrypted control frames (outer fields): never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::control::parse_encrypted_frame(data); +}); diff --git a/fuzz/fuzz_targets/control_message.rs b/fuzz/fuzz_targets/control_message.rs new file mode 100644 index 0000000..db2bd4c --- /dev/null +++ b/fuzz/fuzz_targets/control_message.rs @@ -0,0 +1,11 @@ +//! Fuzzes decrypted control messages from the host: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::control::parse_host_message(data); +}); diff --git a/fuzz/fuzz_targets/enet_datagram.rs b/fuzz/fuzz_targets/enet_datagram.rs new file mode 100644 index 0000000..19e34d2 --- /dev/null +++ b/fuzz/fuzz_targets/enet_datagram.rs @@ -0,0 +1,11 @@ +//! Fuzzes ENet datagrams: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::enet::protocol::parse_datagram(data); +}); diff --git a/fuzz/fuzz_targets/input.rs b/fuzz/fuzz_targets/input.rs new file mode 100644 index 0000000..2c8ec11 --- /dev/null +++ b/fuzz/fuzz_targets/input.rs @@ -0,0 +1,11 @@ +//! Fuzzes INPUT_DATA messages: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::input::parse_input(data); +}); diff --git a/fuzz/fuzz_targets/launch_response.rs b/fuzz/fuzz_targets/launch_response.rs new file mode 100644 index 0000000..e48eabb --- /dev/null +++ b/fuzz/fuzz_targets/launch_response.rs @@ -0,0 +1,11 @@ +//! Fuzzes `/launch` and `/resume` answers: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::http::parse_launch_response(data); +}); diff --git a/fuzz/fuzz_targets/pair_response.rs b/fuzz/fuzz_targets/pair_response.rs new file mode 100644 index 0000000..2c44e80 --- /dev/null +++ b/fuzz/fuzz_targets/pair_response.rs @@ -0,0 +1,11 @@ +//! Fuzzes pairing answers: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::pairing::parse_pair_response(data); +}); diff --git a/fuzz/fuzz_targets/rtp_header.rs b/fuzz/fuzz_targets/rtp_header.rs new file mode 100644 index 0000000..3a92d48 --- /dev/null +++ b/fuzz/fuzz_targets/rtp_header.rs @@ -0,0 +1,11 @@ +//! Fuzzes the RTP header: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::rtp::parse_rtp_header(data); +}); diff --git a/fuzz/fuzz_targets/rtsp_framer.rs b/fuzz/fuzz_targets/rtsp_framer.rs new file mode 100644 index 0000000..da81e86 --- /dev/null +++ b/fuzz/fuzz_targets/rtsp_framer.rs @@ -0,0 +1,23 @@ +//! Fuzzes the RTSP framer over a chunked byte stream: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + // First byte picks the chunk size, so libFuzzer explores message boundaries across pushes. + let Some((&chunk, rest)) = data.split_first() else { return }; + let chunk = usize::from(chunk).max(1); + let mut framer = domistream::rtsp::RtspFramer::new(); + for piece in rest.chunks(chunk) { + if framer.push(piece).is_err() { + return; + } + while let Ok(Some(message)) = framer.next_message() { + let _ = domistream::rtsp::parse_response(&message); + } + } + let _ = framer.finish(); +}); diff --git a/fuzz/fuzz_targets/rtsp_request.rs b/fuzz/fuzz_targets/rtsp_request.rs new file mode 100644 index 0000000..e9dc2b8 --- /dev/null +++ b/fuzz/fuzz_targets/rtsp_request.rs @@ -0,0 +1,11 @@ +//! Fuzzes RTSP requests: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::rtsp::parse_request(data); +}); diff --git a/fuzz/fuzz_targets/rtsp_response.rs b/fuzz/fuzz_targets/rtsp_response.rs new file mode 100644 index 0000000..f155f1a --- /dev/null +++ b/fuzz/fuzz_targets/rtsp_response.rs @@ -0,0 +1,11 @@ +//! Fuzzes RTSP responses: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::rtsp::parse_response(data); +}); diff --git a/fuzz/fuzz_targets/sdp.rs b/fuzz/fuzz_targets/sdp.rs new file mode 100644 index 0000000..7776f0b --- /dev/null +++ b/fuzz/fuzz_targets/sdp.rs @@ -0,0 +1,13 @@ +//! Fuzzes SDP payloads and the host capabilities read from them: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + if let Ok(sdp) = domistream::rtsp::sdp::parse_sdp(data) { + let _ = domistream::rtsp::HostCapabilities::from_sdp(&sdp); + } +}); diff --git a/fuzz/fuzz_targets/server_cert_pem.rs b/fuzz/fuzz_targets/server_cert_pem.rs new file mode 100644 index 0000000..2d7b083 --- /dev/null +++ b/fuzz/fuzz_targets/server_cert_pem.rs @@ -0,0 +1,11 @@ +//! Fuzzes the host certificate PEM (`plaincert`): never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::pairing::ServerCert::from_pem(data); +}); diff --git a/fuzz/fuzz_targets/server_info.rs b/fuzz/fuzz_targets/server_info.rs new file mode 100644 index 0000000..af21874 --- /dev/null +++ b/fuzz/fuzz_targets/server_info.rs @@ -0,0 +1,11 @@ +//! Fuzzes `/serverinfo` answers: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::http::parse_server_info(data); +}); diff --git a/fuzz/fuzz_targets/video_packet.rs b/fuzz/fuzz_targets/video_packet.rs new file mode 100644 index 0000000..f132815 --- /dev/null +++ b/fuzz/fuzz_targets/video_packet.rs @@ -0,0 +1,12 @@ +//! Fuzzes video packets and the frame header: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::video::parse_video_packet(data); + let _ = domistream::video::packet::parse_frame_header(data); +}); diff --git a/fuzz/fuzz_targets/xml.rs b/fuzz/fuzz_targets/xml.rs new file mode 100644 index 0000000..b62d549 --- /dev/null +++ b/fuzz/fuzz_targets/xml.rs @@ -0,0 +1,11 @@ +//! Fuzzes the XML reader behind every HTTP answer: never panics, whatever the bytes. +//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic. +//! How to run: see the comment at the top of `fuzz/Cargo.toml`. + +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &[u8]| { + let _ = domistream::http::xml::parse(data); +}); diff --git a/fuzz/win_sections.c b/fuzz/win_sections.c new file mode 100644 index 0000000..ebd4ab9 --- /dev/null +++ b/fuzz/win_sections.c @@ -0,0 +1,9 @@ +/* Section bounds for SanitizerCoverage's inline 8-bit counters on Windows (COFF), so the fuzz targets link + * without a sanitizer runtime. LLVM puts the counters in ".SCOV$CM"; the linker sorts ".SCOV$CA" before it and + * ".SCOV$CZ" after it, and libFuzzer reads everything in between. compiler-rt does the same in + * sanitizer_coverage_win_sections.cpp, which only ships inside a sanitizer runtime. Built only for MSVC targets + * and only for the fuzz crate, which is never part of a release. */ +#pragma section(".SCOV$CA", read, write) +__declspec(allocate(".SCOV$CA")) unsigned char __start___sancov_cntrs[1] = {0}; +#pragma section(".SCOV$CZ", read, write) +__declspec(allocate(".SCOV$CZ")) unsigned char __stop___sancov_cntrs[1] = {0};