authopt_fuzz.cc 655 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <stddef.h>
  2. #include <stdio.h>
  3. #include <stdint.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6. extern "C" {
  7. #include "auth-options.h"
  8. int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
  9. {
  10. char *cp = (char *)malloc(size + 1);
  11. struct sshauthopt *opts = NULL, *merge = NULL, *add = sshauthopt_new();
  12. if (cp == NULL || add == NULL)
  13. goto out;
  14. memcpy(cp, data, size);
  15. cp[size] = '\0';
  16. if ((opts = sshauthopt_parse(cp, NULL)) == NULL)
  17. goto out;
  18. if ((merge = sshauthopt_merge(opts, add, NULL)) == NULL)
  19. goto out;
  20. out:
  21. free(cp);
  22. sshauthopt_free(add);
  23. sshauthopt_free(opts);
  24. sshauthopt_free(merge);
  25. return 0;
  26. }
  27. } // extern "C"