/src/gnutls/fuzz/gnutls_x509_crl_parser_fuzzer.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2020 Dmitry Baryshkov |
3 | | * |
4 | | * This file is part of GnuTLS. |
5 | | * |
6 | | * The GnuTLS is free software; you can redistribute it and/or |
7 | | * modify it under the terms of the GNU Lesser General Public License |
8 | | * as published by the Free Software Foundation; either version 2.1 of |
9 | | * the License, or (at your option) any later version. |
10 | | * |
11 | | * This library is distributed in the hope that it will be useful, but |
12 | | * WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | | * Lesser General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU Lesser General Public License |
17 | | * along with this program. If not, see <https://www.gnu.org/licenses/> |
18 | | * |
19 | | */ |
20 | | |
21 | | #include <assert.h> |
22 | | #include <stdint.h> |
23 | | |
24 | | #include <gnutls/gnutls.h> |
25 | | #include <gnutls/x509.h> |
26 | | |
27 | | #include "fuzzer.h" |
28 | | |
29 | | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
30 | 23.3k | { |
31 | 23.3k | gnutls_datum_t raw; |
32 | 23.3k | gnutls_datum_t out; |
33 | 23.3k | gnutls_x509_crl_t crl; |
34 | 23.3k | int ret; |
35 | | |
36 | 23.3k | raw.data = (unsigned char *)data; |
37 | 23.3k | raw.size = size; |
38 | | |
39 | 23.3k | ret = gnutls_x509_crl_init(&crl); |
40 | 23.3k | assert(ret >= 0); |
41 | | |
42 | 23.3k | ret = gnutls_x509_crl_import(crl, &raw, GNUTLS_X509_FMT_DER); |
43 | 23.3k | if (ret >= 0) { |
44 | 9.05k | ret = gnutls_x509_crl_print(crl, GNUTLS_CRT_PRINT_FULL, &out); |
45 | 9.05k | assert(ret >= 0); |
46 | 9.05k | gnutls_free(out.data); |
47 | 9.05k | } |
48 | 23.3k | gnutls_x509_crl_deinit(crl); |
49 | | |
50 | 23.3k | return 0; |
51 | 23.3k | } |