swadhinbiswas 📦 v2.0.8: security fixes, documentation, testing improvements · 7/28/2026
3e270a0
27 lines · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//! Fuzz target for gRPC/protobuf parsing.
//!
//! Tests that the gRPC decoder handles malformed input gracefully
//! without panicking or memory safety issues.

#![no_main]
use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
    // Test raw bytes decoder with arbitrary input
    // This covers the gRPC message parsing logic

    // Simulate a gRPC message with fuzzed payload
    if data.is_empty() {
        return;
    }

    // Test that we can handle arbitrary byte sequences
    // without panicking
    let _ = std::str::from_utf8(data);

    // Test JSON parsing on the data (gRPC often wraps JSON)
    if let Ok(s) = std::str::from_utf8(data) {
        let _ = serde_json::from_str::<serde_json::Value>(s);
    }
});