Blame fuzz/gnutls_base64_decoder_fuzzer.c
|
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 <stdint.h>
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <gnutls/gnutls.h>
|
|
Packit Service |
4684c1 |
#include "fuzzer.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
gnutls_datum_t raw = {.data = (unsigned char *)data, .size = size};
|
|
Packit Service |
4684c1 |
gnutls_datum_t out;
|
|
Packit Service |
4684c1 |
unsigned char result[50];
|
|
Packit Service |
4684c1 |
size_t result_size = sizeof(result);
|
|
Packit Service |
4684c1 |
int ret;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
ret = gnutls_pem_base64_decode2(NULL, &raw, &out;;
|
|
Packit Service |
4684c1 |
if (ret >= 0)
|
|
Packit Service |
4684c1 |
gnutls_free(out.data);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
gnutls_pem_base64_decode(NULL, &raw, result, &result_size);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
ret = gnutls_base64_decode2(&raw, &out;;
|
|
Packit Service |
4684c1 |
if (ret >= 0)
|
|
Packit Service |
4684c1 |
gnutls_free(out.data);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|