Coverage Report

Created: 2026-03-31 06:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gnutls/fuzz/gnutls_set_trust_file_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 <config.h>
20
21
#include <stdint.h>
22
23
#include <gnutls/gnutls.h>
24
#include "fuzzer.h"
25
26
static const uint8_t *g_data;
27
static size_t g_size;
28
29
#if !defined _WIN32 && defined HAVE_FMEMOPEN
30
#include <stdio.h>
31
#include <string.h>
32
#include <dlfcn.h>
33
FILE *fopen(const char *pathname, const char *mode)
34
5
{
35
5
  FILE *(*libc_fopen)(const char *, const char *) =
36
5
    (FILE * (*)(const char *, const char *))
37
5
      dlsym(RTLD_NEXT, "fopen");
38
39
5
  if (!strcmp(pathname, "ca_or_crl"))
40
0
    return fmemopen((void *)g_data, g_size, mode);
41
42
5
  return libc_fopen(pathname, mode);
43
5
}
44
#endif
45
46
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
47
615
{
48
615
  g_data = data;
49
615
  g_size = size;
50
51
615
  gnutls_certificate_credentials_t creds;
52
615
  gnutls_certificate_allocate_credentials(&creds);
53
615
  gnutls_certificate_set_x509_trust_file(creds, "ca_or_crl",
54
615
                 GNUTLS_X509_FMT_PEM);
55
615
  gnutls_certificate_set_x509_crl_file(creds, "ca_or_crl",
56
615
               GNUTLS_X509_FMT_PEM);
57
615
  gnutls_certificate_free_credentials(creds);
58
59
615
  return 0;
60
615
}