fuzz_json_decode.cc 833 B

12345678910111213141516171819202122232425262728293031
  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. #include <ua_types.h>
  8. #include <ua_types_generated_handling.h>
  9. #include "ua_types_encoding_json.h"
  10. /*
  11. ** Main entry point. The fuzzer invokes this function with each
  12. ** fuzzed input.
  13. */
  14. extern "C" int
  15. LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
  16. UA_ByteString buf;
  17. buf.data = (UA_Byte*)data;
  18. buf.length = size;
  19. UA_Variant out;
  20. UA_Variant_init(&out);
  21. UA_StatusCode retval = UA_decodeJson(&buf, &out, &UA_TYPES[UA_TYPES_VARIANT]);
  22. if(retval == UA_STATUSCODE_GOOD)
  23. UA_Variant_deleteMembers(&out);
  24. return 0;
  25. }