/src/pybind11/tests/fuzz/fuzz_input.h
Line | Count | Source |
1 | | // Copyright (c) 2026 The pybind Community. |
2 | | |
3 | | #pragma once |
4 | | |
5 | | #include <cstddef> |
6 | | #include <cstdint> |
7 | | #include <string> |
8 | | |
9 | | #include <fuzzer/FuzzedDataProvider.h> |
10 | | |
11 | | namespace pybind11_fuzz { |
12 | | |
13 | | struct input { |
14 | | std::string code; |
15 | | std::string attr_name; |
16 | | std::string decimal_text; |
17 | | std::string decimal_attr; |
18 | | std::string text; |
19 | | }; |
20 | | |
21 | 2.39k | inline input decode_input(const std::uint8_t *data, std::size_t size) { |
22 | 2.39k | FuzzedDataProvider fdp(data, size); |
23 | 2.39k | input result; |
24 | 2.39k | result.code = fdp.ConsumeRandomLengthString(); |
25 | 2.39k | result.attr_name = fdp.ConsumeRandomLengthString(); |
26 | 2.39k | result.decimal_text = fdp.ConsumeRandomLengthString(); |
27 | 2.39k | result.decimal_attr = fdp.ConsumeRandomLengthString(); |
28 | 2.39k | result.text = fdp.ConsumeRandomLengthString(); |
29 | 2.39k | return result; |
30 | 2.39k | } |
31 | | |
32 | | } // namespace pybind11_fuzz |