/src/gnutls/fuzz/gnutls_base64_decoder_fuzzer.c
Line | Count | Source |
1 | | /* |
2 | | # Copyright 2017 Red Hat, Inc. |
3 | | # |
4 | | # Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | # you may not use this file except in compliance with the License. |
6 | | # You may obtain a copy of the License at |
7 | | # |
8 | | # https://www.apache.org/licenses/LICENSE-2.0 |
9 | | # |
10 | | # Unless required by applicable law or agreed to in writing, software |
11 | | # distributed under the License is distributed on an "AS IS" BASIS, |
12 | | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | # See the License for the specific language governing permissions and |
14 | | # limitations under the License. |
15 | | # |
16 | | ################################################################################ |
17 | | */ |
18 | | |
19 | | #include <stdint.h> |
20 | | |
21 | | #include <gnutls/gnutls.h> |
22 | | #include "fuzzer.h" |
23 | | |
24 | | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
25 | 480 | { |
26 | 480 | gnutls_datum_t raw = { .data = (unsigned char *)data, .size = size }; |
27 | 480 | gnutls_datum_t out; |
28 | 480 | unsigned char result[50]; |
29 | 480 | size_t result_size = sizeof(result); |
30 | 480 | int ret; |
31 | | |
32 | 480 | ret = gnutls_pem_base64_decode2(NULL, &raw, &out); |
33 | 480 | if (ret >= 0) |
34 | 243 | gnutls_free(out.data); |
35 | | |
36 | 480 | gnutls_pem_base64_decode(NULL, &raw, result, &result_size); |
37 | | |
38 | 480 | ret = gnutls_base64_decode2(&raw, &out); |
39 | 480 | if (ret >= 0) |
40 | 217 | gnutls_free(out.data); |
41 | | |
42 | 480 | return 0; |
43 | 480 | } |