/src/usbguard/src/Tests/Fuzzers/fuzzer-uevent.cpp
Line | Count | Source |
1 | | // |
2 | | // Copyright (C) 2018 Red Hat, Inc. |
3 | | // |
4 | | // This program is free software; you can redistribute it and/or modify |
5 | | // it under the terms of the GNU General Public License as published by |
6 | | // the Free Software Foundation; either version 2 of the License, or |
7 | | // (at your option) any later version. |
8 | | // |
9 | | // This program is distributed in the hope that it will be useful, |
10 | | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | | // GNU General Public License for more details. |
13 | | // |
14 | | // You should have received a copy of the GNU General Public License |
15 | | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | | // |
17 | | // Authors: Allen Webb <allenwebb@google.com> |
18 | | // |
19 | | #include <unistd.h> |
20 | | |
21 | | #include <cstdint> |
22 | | |
23 | | #include <tao/pegtl.hpp> |
24 | | #if TAO_PEGTL_VERSION_MAJOR >= 3 |
25 | | #include <tao/pegtl/contrib/trace.hpp> |
26 | | #else |
27 | | #include <tao/pegtl/contrib/tracer.hpp> |
28 | | #endif |
29 | | #include <UEvent.hpp> |
30 | | |
31 | | using namespace usbguard; |
32 | | |
33 | | // Silence warning |
34 | | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); |
35 | | |
36 | | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) |
37 | 1.33k | { |
38 | 1.33k | try { |
39 | 1.33k | UEvent uevent = UEvent::fromString(std::string(data, data + size)); |
40 | 1.33k | } |
41 | 1.33k | catch (const tao::pegtl::parse_error& ex) { |
42 | | // Parser errors are ok. |
43 | 224 | } |
44 | | |
45 | 1.33k | return 0; |
46 | 1.33k | } |
47 | | |
48 | | /* vim: set ts=2 sw=2 et */ |