/src/gnutls/fuzz/gnutls_ocsp_resp_parser_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 <assert.h> |
20 | | #include <stdint.h> |
21 | | |
22 | | #include <gnutls/gnutls.h> |
23 | | #include <gnutls/ocsp.h> |
24 | | |
25 | | #include "fuzzer.h" |
26 | | |
27 | | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
28 | 23.8k | { |
29 | 23.8k | gnutls_datum_t raw; |
30 | 23.8k | gnutls_datum_t out; |
31 | 23.8k | gnutls_ocsp_resp_t resp; |
32 | 23.8k | int ret; |
33 | | |
34 | 23.8k | raw.data = (unsigned char *)data; |
35 | 23.8k | raw.size = size; |
36 | | |
37 | 23.8k | ret = gnutls_ocsp_resp_init(&resp); |
38 | 23.8k | assert(ret >= 0); |
39 | | |
40 | 23.8k | ret = gnutls_ocsp_resp_import(resp, &raw); |
41 | 23.8k | if (ret >= 0) { |
42 | 9.37k | ret = gnutls_ocsp_resp_print(resp, GNUTLS_OCSP_PRINT_FULL, |
43 | 9.37k | &out); |
44 | 9.37k | assert(ret >= 0); |
45 | 9.37k | gnutls_free(out.data); |
46 | 9.37k | } |
47 | | |
48 | 23.8k | gnutls_ocsp_resp_deinit(resp); |
49 | 23.8k | return 0; |
50 | 23.8k | } |