Skip to content

fix(rust): handle panics from fuzz-found edge cases#3481

Merged
chaokunyang merged 1 commit intoapache:mainfrom
utafrali:fix/issue-3480-rust-several-panics-found-by-cargo-fuzz
Mar 15, 2026
Merged

fix(rust): handle panics from fuzz-found edge cases#3481
chaokunyang merged 1 commit intoapache:mainfrom
utafrali:fix/issue-3480-rust-several-panics-found-by-cargo-fuzz

Conversation

@utafrali
Copy link
Contributor

Closes #3480

Cargo-fuzz was hitting several panics in the serialization code. Switched from unwrap/unreachable to proper error handling:

  • field_id calculation now uses checked_add to catch overflows instead of panicking
  • field name decoding switched from unwrap() to Result propagation
  • byte_to_encoding now returns Result for unknown encoding bytes instead of using unreachable!()
  • MetaStringBytes::new() updated to return Result so callers can handle invalid inputs

All of these return the same error type so the call sites already handle it correctly.

Why?

Fuzzing found inputs that triggered panics. Better to return an error than crash.

What does this PR do?

Replaces panics with proper error returns in the metadata serialization paths.

Related issues

#3480

AI Contribution Checklist

N/A

Does this PR introduce any user-facing change?

No. Valid inputs behave identically. Invalid/malformed data now returns an error instead of panicking.

Benchmark

N/A

Cargo-fuzz was hitting several panics in the serialization code. Replace
unwrap/unreachable with proper error handling:

- field_id calculation now uses checked_add to catch overflows
- field name decoding switched from unwrap() to Result propagation
- byte_to_encoding now returns Result for unknown encoding bytes
- MetaStringBytes::new() updated to return Result

Closes apache#3480
Copy link
Collaborator

@chaokunyang chaokunyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chaokunyang chaokunyang merged commit 5fc06f1 into apache:main Mar 15, 2026
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Rust] several panics found by cargo-fuzz

2 participants