/src/open62541_15/tests/fuzz/fuzz_config_json.cc
Line | Count | Source |
1 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
2 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
4 | | * |
5 | | * Fuzzer for JSON configuration parsing (UA_Server_newFromFile). |
6 | | */ |
7 | | |
8 | | #include <open62541/server.h> |
9 | | #include <open62541/server_config_default.h> |
10 | | #include <open62541/server_config_file_based.h> |
11 | | |
12 | | extern "C" int |
13 | 4.57k | LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
14 | 4.57k | if(size < 1) |
15 | 0 | return 0; |
16 | | |
17 | 4.57k | UA_ByteString buf; |
18 | 4.57k | buf.data = (UA_Byte*)(uintptr_t)data; |
19 | 4.57k | buf.length = size; |
20 | | |
21 | | /* Fuzz server config parsing from JSON */ |
22 | 4.57k | UA_Server *server = UA_Server_newFromFile(buf); |
23 | 4.57k | if(server) |
24 | 3.27k | UA_Server_delete(server); |
25 | | |
26 | 4.57k | return 0; |
27 | 4.57k | } |