Skip to content

fix(rust): fix several panics detected by cargo-fuzz#3483

Open
BaldDemian wants to merge 1 commit intoapache:mainfrom
BaldDemian:cargo-fuzz-fix
Open

fix(rust): fix several panics detected by cargo-fuzz#3483
BaldDemian wants to merge 1 commit intoapache:mainfrom
BaldDemian:cargo-fuzz-fix

Conversation

@BaldDemian
Copy link

Why?

Fix several new panics when feeding corner-case input found by cargo-fuzz

What does this PR do?

  • In rust/README.md, the right command to run all tests seems to be cargo test --workspace. Run cargo test --features tests will get:
    Screenshot 2026-03-15 at 6 16 51 AM

  • In rust/fory-core/src/meta/type_meta.rs,

  • In rust/fory-core/src/row/bit_util.rs, use saturating_add/mul to prevent potential overflow panic. But would it be better to return error instead of saturating_add/mul ?🤔

  • In rust/fory-core/src/row/reader.rs, direct access into slice using [] may cause out-of-bounds panic.

  • In rust/fory-core/src/serializer/collection.rs, rust/fory-core/src/serializer/map.rs and rust/fory-core/src/serializer/primitive_list.rs, we should check the remaining bytes in the buffer before allocating Vec. This can also prevent OOM.

  • In rust/fory-core/src/serializer/skip.rs, generics.first().unwrap() and generics.get(1).unwrap() will panic if the size of generics is not long enough.

Related issues

N/A

AI Contribution Checklist

N/A

Does this PR introduce any user-facing change?

N/A

Benchmark

This PR only adds additional check in case of corner-case input and thus won't has major influence on the performance.

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.

1 participant