/src/openssl32/fuzz/punycode.c
Line  | Count  | Source (jump to first uncovered line)  | 
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  |  |  | 
10  |  | #include "crypto/punycode.h"  | 
11  |  | #include "internal/nelem.h"  | 
12  |  | #include <openssl/crypto.h>  | 
13  |  | #include "fuzzer.h"  | 
14  |  |  | 
15  |  | #include <stdio.h>  | 
16  |  | #include <string.h>  | 
17  |  |  | 
18  |  | int FuzzerInitialize(int *argc, char ***argv)  | 
19  | 108  | { | 
20  | 108  |     return 1;  | 
21  | 108  | }  | 
22  |  |  | 
23  |  | int FuzzerTestOneInput(const uint8_t *buf, size_t len)  | 
24  | 47.5k  | { | 
25  | 47.5k  |     char *b;  | 
26  | 47.5k  |     unsigned int out[16], outlen = OSSL_NELEM(out);  | 
27  | 47.5k  |     char outc[16];  | 
28  |  |  | 
29  | 47.5k  |     b = OPENSSL_malloc(len + 1);  | 
30  | 47.5k  |     if (b != NULL) { | 
31  | 34.8k  |         ossl_punycode_decode((const char *)buf, len, out, &outlen);  | 
32  | 34.8k  |         memcpy(b, buf, len);  | 
33  | 34.8k  |         b[len] = '\0';  | 
34  | 34.8k  |         ossl_a2ulabel(b, outc, sizeof(outc));  | 
35  | 34.8k  |         OPENSSL_free(b);  | 
36  | 34.8k  |     }  | 
37  | 47.5k  |     return 0;  | 
38  | 47.5k  | }  | 
39  |  |  | 
40  |  | void FuzzerCleanup(void)  | 
41  | 0  | { | 
42  | 0  | }  |