fuzz_binary_message.c 990 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. #include "fuzz_common.h"
  5. /*
  6. ** Main entry point. The fuzzer invokes this function with each
  7. ** fuzzed input.
  8. */
  9. 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. config.logger = UA_Log_Stdout;
  16. msg.length = size;
  17. msg.data = data;
  18. UA_Boolean reallocated = UA_FALSE;
  19. UA_StatusCode retval = UA_Connection_completeMessages(&c, &msg, &reallocated);
  20. if(retval == UA_STATUSCODE_GOOD && msg.length > 0)
  21. UA_Server_processBinaryMessage(server, &c, &msg);
  22. UA_Server_delete(server);
  23. UA_Connection_deleteMembers(&c);
  24. return 0;
  25. }