fuzz_url.c 666 B

123456789101112131415161718192021222324
  1. // Copyright 2007 - 2022, Alan Antonuk and the rabbitmq-c contributors.
  2. // SPDX-License-Identifier: mit
  3. #include <inttypes.h>
  4. #include <stddef.h>
  5. #include <stdint.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <rabbitmq-c/amqp.h>
  9. extern int LLVMFuzzerTestOneInput(const char *data, size_t size) {
  10. // amqp_parse_url expects null-terminated string that it can modify,
  11. // LLVMFuzzer expects that data will not be modified and won't necessarily
  12. // null terminate the string, so do that here.
  13. char* in = malloc(size + 1);
  14. memcpy(in, data, size);
  15. in[size] = '\0';
  16. struct amqp_connection_info ci;
  17. amqp_parse_url(in, &ci);
  18. free(in);
  19. return 0;
  20. }