/src/open62541/tests/fuzz/fuzz_pubsub_connection_config.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 | | */ |
6 | | |
7 | | #include <open62541/server_pubsub.h> |
8 | | #include <open62541/types.h> |
9 | | |
10 | 4.51k | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
11 | 4.51k | if(size < 10) |
12 | 12 | return 0; |
13 | | |
14 | 4.50k | UA_ByteString msg = {size, (UA_Byte *) (void *) data}; |
15 | 4.50k | UA_PubSubConnectionConfig config; |
16 | 4.50k | memset(&config, 0, sizeof(UA_PubSubConnectionConfig)); |
17 | | |
18 | | /* Decode some fields from the fuzzer input */ |
19 | 4.50k | UA_decodeBinary(&msg, &config.name, &UA_TYPES[UA_TYPES_STRING], NULL); |
20 | 4.50k | UA_decodeBinary(&msg, &config.address, &UA_TYPES[UA_TYPES_VARIANT], NULL); |
21 | | |
22 | 4.50k | UA_PubSubConnectionConfig config2; |
23 | 4.50k | UA_StatusCode retval = UA_PubSubConnectionConfig_copy(&config, &config2); |
24 | 4.50k | if(retval == UA_STATUSCODE_GOOD) { |
25 | 4.50k | UA_PubSubConnectionConfig_clear(&config2); |
26 | 4.50k | } |
27 | 4.50k | UA_PubSubConnectionConfig_clear(&config); |
28 | | |
29 | 4.50k | return 0; |
30 | 4.51k | } |