Coverage Report

Created: 2024-11-25 06:31

/src/gnutls/fuzz/gnutls_x509_crq_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
17.5k
{
31
17.5k
  gnutls_datum_t raw;
32
17.5k
  gnutls_datum_t out;
33
17.5k
  gnutls_x509_crq_t crq;
34
17.5k
  int ret;
35
36
17.5k
  raw.data = (unsigned char *)data;
37
17.5k
  raw.size = size;
38
39
17.5k
  ret = gnutls_x509_crq_init(&crq);
40
17.5k
  assert(ret >= 0);
41
42
17.5k
  ret = gnutls_x509_crq_import(crq, &raw, GNUTLS_X509_FMT_DER);
43
17.5k
  if (ret >= 0) {
44
7.07k
    ret = gnutls_x509_crq_print(crq, GNUTLS_CRT_PRINT_FULL, &out);
45
7.07k
    assert(ret >= 0);
46
7.07k
    gnutls_free(out.data);
47
7.07k
  }
48
17.5k
  gnutls_x509_crq_deinit(crq);
49
50
17.5k
  return 0;
51
17.5k
}