/src/arm-ffa/fuzz/fuzz_targets/mem_transaction_desc.rs
Line | Count | Source |
1 | | // SPDX-FileCopyrightText: Copyright The arm-ffa Contributors. |
2 | | // SPDX-License-Identifier: MIT OR Apache-2.0 |
3 | | |
4 | | //! Unpacks memory descriptors from the test data then packs them. |
5 | | |
6 | | #![no_main] |
7 | | |
8 | | use arm_ffa::memory_management::MemTransactionDesc; |
9 | | use libfuzzer_sys::fuzz_target; |
10 | | |
11 | | fuzz_target!(|data: &[u8]| { |
12 | | let Ok((transaction, perms, regions)) = MemTransactionDesc::unpack(data) else { |
13 | | return; |
14 | | }; |
15 | | |
16 | | // try to roundtrip as many entries as possible |
17 | 201 | let constituents: Vec<_> = regions.map_or(vec![], |v| v.collect()); |
18 | 176k | let access_descriptors: Vec<_> = perms.filter_map(|it| it.ok()).collect(); |
19 | | |
20 | | let mut buf = vec![0; data.len() * 3]; |
21 | | let _len = transaction.pack(&constituents, &access_descriptors, &mut buf); |
22 | | }); |