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