|
Packit Service |
4684c1 |
/*
|
|
Packit Service |
4684c1 |
# Copyright 2017 Red Hat, Inc.
|
|
Packit Service |
4684c1 |
#
|
|
Packit Service |
4684c1 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
Packit Service |
4684c1 |
# you may not use this file except in compliance with the License.
|
|
Packit Service |
4684c1 |
# You may obtain a copy of the License at
|
|
Packit Service |
4684c1 |
#
|
|
Packit Service |
4684c1 |
# https://www.apache.org/licenses/LICENSE-2.0
|
|
Packit Service |
4684c1 |
#
|
|
Packit Service |
4684c1 |
# Unless required by applicable law or agreed to in writing, software
|
|
Packit Service |
4684c1 |
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit Service |
4684c1 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit Service |
4684c1 |
# See the License for the specific language governing permissions and
|
|
Packit Service |
4684c1 |
# limitations under the License.
|
|
Packit Service |
4684c1 |
#
|
|
Packit Service |
4684c1 |
################################################################################
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <config.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <stdint.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <gnutls/gnutls.h>
|
|
Packit Service |
4684c1 |
#include "fuzzer.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static const uint8_t *g_data;
|
|
Packit Service |
4684c1 |
static size_t g_size;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#if ! defined _WIN32 && defined HAVE_FMEMOPEN
|
|
Packit Service |
4684c1 |
#include <stdio.h>
|
|
Packit Service |
4684c1 |
#include <string.h>
|
|
Packit Service |
4684c1 |
#include <dlfcn.h>
|
|
Packit Service |
4684c1 |
FILE *fopen(const char *pathname, const char *mode)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
FILE *(*libc_fopen)(const char *, const char *) =
|
|
Packit Service |
4684c1 |
(FILE *(*)(const char *, const char *)) dlsym (RTLD_NEXT, "fopen");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
if (!strcmp(pathname, "ca_or_crl"))
|
|
Packit Service |
4684c1 |
return fmemopen((void *) g_data, g_size, mode);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return libc_fopen(pathname, mode);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
g_data = data;
|
|
Packit Service |
4684c1 |
g_size = size;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_certificate_credentials_t creds;
|
|
Packit Service |
4684c1 |
gnutls_certificate_allocate_credentials(&creds);
|
|
Packit Service |
4684c1 |
gnutls_certificate_set_x509_trust_file(creds, "ca_or_crl", GNUTLS_X509_FMT_PEM);
|
|
Packit Service |
4684c1 |
gnutls_certificate_set_x509_crl_file(creds, "ca_or_crl", GNUTLS_X509_FMT_PEM);
|
|
Packit Service |
4684c1 |
gnutls_certificate_free_credentials(creds);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|