fuzz_binary_message.cc 1019 B

1234567891011121314151617181920212223242526272829303132
  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. #include "fuzz_common.h"
  5. /*
  6. ** Main entry point. The fuzzer invokes this function with each
  7. ** fuzzed input.
  8. */
  9. extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
  10. UA_Connection c = createDummyConnection();
  11. UA_ServerConfig config = UA_ServerConfig_standard;
  12. config.logger = UA_Log_Stdout;
  13. UA_Server *server = UA_Server_new(config);
  14. UA_ByteString msg = {
  15. size, //length
  16. const_cast<UA_Byte*>(data) //data
  17. };
  18. config.logger = UA_Log_Stdout;
  19. UA_Boolean reallocated = UA_FALSE;
  20. UA_StatusCode retval = UA_Connection_completeMessages(&c, &msg, &reallocated);
  21. if(retval == UA_STATUSCODE_GOOD && msg.length > 0)
  22. UA_Server_processBinaryMessage(server, &c, &msg);
  23. UA_Server_delete(server);
  24. UA_Connection_deleteMembers(&c);
  25. return 0;
  26. }