Skip to content

Implement Arbitrary for more PDU structs #1122

@CBenoit

Description

Provide arbitrary::Arbitrary (derive or manual impl) for a first batch of PDUs so structured fuzzing can start.

Approach

  • Prefer #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] for simple types
  • Use manual impl Arbitrary for types with invariants (length fields, constraints, dependent fields)
  • Bias toward “mostly valid” generation so fuzzing reaches deeper logic
  • Add a generators::AnyPdu (or similar) enum used by fuzz targets which can produce a curated set of PDUs

Add Arbitrary derivations (or manual impls)

For most “plain data” structs/enums:

#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SomePdu { /* … */ }

Handle invariants (manual Arbitrary where needed)

Some PDUs have constraints that derive(Arbitrary) can’t express well (length fields, restricted enums, “must be non-empty”, etc.). In those cases:

  • either implement Arbitrary manually and reject invalid values by returning Err(arbitrary::Error::IncorrectFormat),
  • or generate a “raw” value and then sanitize it (clamp lengths, fix flags, etc.).

The goal is: generated PDUs should be “mostly valid”, so we reach deeper code paths (not fail immediately on trivial validation).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-coreArea: Core tierfuzzingCrashs and other bugs found by fuzzing

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions