Blame fuzz/gnutls_ocsp_resp_parser_fuzzer.c

Packit aea12f
/*
Packit aea12f
# Copyright 2017 Red Hat, Inc.
Packit aea12f
#
Packit aea12f
# Licensed under the Apache License, Version 2.0 (the "License");
Packit aea12f
# you may not use this file except in compliance with the License.
Packit aea12f
# You may obtain a copy of the License at
Packit aea12f
#
Packit aea12f
#      https://www.apache.org/licenses/LICENSE-2.0
Packit aea12f
#
Packit aea12f
# Unless required by applicable law or agreed to in writing, software
Packit aea12f
# distributed under the License is distributed on an "AS IS" BASIS,
Packit aea12f
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit aea12f
# See the License for the specific language governing permissions and
Packit aea12f
# limitations under the License.
Packit aea12f
#
Packit aea12f
################################################################################
Packit aea12f
*/
Packit aea12f
Packit aea12f
#include <assert.h>
Packit aea12f
#include <stdint.h>
Packit aea12f
Packit aea12f
#include <gnutls/gnutls.h>
Packit aea12f
#include <gnutls/ocsp.h>
Packit aea12f
Packit aea12f
#include "fuzzer.h"
Packit aea12f
Packit aea12f
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
Packit aea12f
{
Packit aea12f
	gnutls_datum_t raw;
Packit aea12f
	gnutls_datum_t out;
Packit aea12f
	gnutls_ocsp_resp_t resp;
Packit aea12f
	int ret;
Packit aea12f
Packit aea12f
	raw.data = (unsigned char *)data;
Packit aea12f
	raw.size = size;
Packit aea12f
Packit aea12f
	ret = gnutls_ocsp_resp_init(&resp);
Packit aea12f
	assert(ret >= 0);
Packit aea12f
Packit aea12f
	ret = gnutls_ocsp_resp_import(resp, &raw;;
Packit aea12f
	if (ret >= 0) {
Packit aea12f
		ret = gnutls_ocsp_resp_print(resp, GNUTLS_OCSP_PRINT_FULL, &out;;
Packit aea12f
		assert(ret >= 0);
Packit aea12f
		gnutls_free(out.data);
Packit aea12f
	}
Packit aea12f
Packit aea12f
	gnutls_ocsp_resp_deinit(resp);
Packit aea12f
	return 0;
Packit aea12f
}