/src/open62541_15/tests/fuzz/fuzz_json_decode.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 | | * Copyright 2018 (c) Fraunhofer IOSB (Author: Lukas Meling) |
6 | | */ |
7 | | |
8 | | #include <open62541/types.h> |
9 | | |
10 | | /* |
11 | | ** Main entry point. The fuzzer invokes this function with each |
12 | | ** fuzzed input. |
13 | | */ |
14 | | extern "C" int |
15 | 14.3k | LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { |
16 | 14.3k | UA_ByteString buf; |
17 | 14.3k | buf.data = (UA_Byte*)data; |
18 | 14.3k | buf.length = size; |
19 | | |
20 | 14.3k | UA_Variant out; |
21 | 14.3k | UA_Variant_init(&out); |
22 | | |
23 | 14.3k | UA_StatusCode retval = UA_decodeJson(&buf, &out, &UA_TYPES[UA_TYPES_VARIANT], NULL); |
24 | 14.3k | if(retval == UA_STATUSCODE_GOOD) |
25 | 3.75k | UA_Variant_clear(&out); |
26 | | |
27 | 14.3k | return 0; |
28 | 14.3k | } |