Blame fuzz/gnutls_base64_encoder_fuzzer.c

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