punycode.c 982 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include "crypto/punycode.h"
  10. #include "internal/nelem.h"
  11. #include <openssl/crypto.h>
  12. #include "fuzzer.h"
  13. #include <stdio.h>
  14. #include <string.h>
  15. int FuzzerInitialize(int *argc, char ***argv)
  16. {
  17. return 1;
  18. }
  19. int FuzzerTestOneInput(const uint8_t *buf, size_t len)
  20. {
  21. char *b;
  22. unsigned int out[16], outlen = OSSL_NELEM(out);
  23. char outc[16];
  24. b = OPENSSL_malloc(len + 1);
  25. if (b != NULL) {
  26. ossl_punycode_decode((const char *)buf, len, out, &outlen);
  27. memcpy(b, buf, len);
  28. b[len] = '\0';
  29. ossl_a2ulabel(b, outc, sizeof(outc));
  30. OPENSSL_free(b);
  31. }
  32. return 0;
  33. }
  34. void FuzzerCleanup(void)
  35. {
  36. }