diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-03-08 17:01:59 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-03-09 13:22:38 +0100 |
commit | 07eb6aa85c2357b3d9ed19fd78fb69ac26f4ef9e (patch) | |
tree | ec25c095461f8d609d0fdd75f337e9def9875bee /devel | |
parent | 03fc1046cfe83d14865756784367f71ba4868212 (diff) | |
download | gnutls-07eb6aa85c2357b3d9ed19fd78fb69ac26f4ef9e.tar.gz |
fuzz: added OCSP structure parsers
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'devel')
-rw-r--r-- | devel/fuzz/Makefile | 12 | ||||
-rw-r--r-- | devel/fuzz/gnutls_ocsp_req_parser_fuzzer.cc | 47 | ||||
-rw-r--r-- | devel/fuzz/gnutls_ocsp_resp_parser_fuzzer.cc | 47 |
3 files changed, 104 insertions, 2 deletions
diff --git a/devel/fuzz/Makefile b/devel/fuzz/Makefile index d45fc7bd57..dfdbc9c765 100644 --- a/devel/fuzz/Makefile +++ b/devel/fuzz/Makefile @@ -23,7 +23,14 @@ COMMON=-I../../lib/includes -L../../lib/.libs -Wl,-rpath=../../lib/.libs -lgnutl all: gnutls_pkcs7_parser_fuzzer gnutls_client_fuzzer gnutls_dn_parser_fuzzer \ gnutls_openpgp_cert_parser_fuzzer gnutls_pkcs7_parser_fuzzer gnutls_pkcs8_key_parser_fuzzer \ gnutls_private_key_parser_fuzzer gnutls_server_fuzzer gnutls_x509_parser_fuzzer \ - gnutls_reverse_idna_parser_fuzzer gnutls_idna_parser_fuzzer + gnutls_reverse_idna_parser_fuzzer gnutls_idna_parser_fuzzer gnutls_ocsp_resp_parser_fuzzer \ + gnutls_ocsp_req_parser_fuzzer + +gnutls_ocsp_req_parser_fuzzer: gnutls_ocsp_req_parser_fuzzer.cc + $(CC) $(CFLAGS) main.c $^ $(COMMON) -o $@ + +gnutls_ocsp_resp_parser_fuzzer: gnutls_ocsp_resp_parser_fuzzer.cc + $(CC) $(CFLAGS) main.c $^ $(COMMON) -o $@ gnutls_pkcs7_parser_fuzzer: gnutls_pkcs7_parser_fuzzer.cc $(CC) $(CFLAGS) main.c $^ $(COMMON) -o $@ @@ -59,4 +66,5 @@ clean: rm -f gnutls_pkcs7_parser_fuzzer gnutls_client_fuzzer gnutls_dn_parser_fuzzer \ gnutls_openpgp_cert_parser_fuzzer gnutls_pkcs7_parser_fuzzer gnutls_pkcs8_key_parser_fuzzer \ gnutls_private_key_parser_fuzzer gnutls_server_fuzzer gnutls_x509_parser_fuzzer \ - gnutls_idna_parser_fuzzer gnutls_reverse_idna_parser_fuzzer + gnutls_idna_parser_fuzzer gnutls_reverse_idna_parser_fuzzer gnutls_ocsp_resp_parser_fuzzer \ + gnutls_ocsp_req_parser_fuzzer diff --git a/devel/fuzz/gnutls_ocsp_req_parser_fuzzer.cc b/devel/fuzz/gnutls_ocsp_req_parser_fuzzer.cc new file mode 100644 index 0000000000..af99056158 --- /dev/null +++ b/devel/fuzz/gnutls_ocsp_req_parser_fuzzer.cc @@ -0,0 +1,47 @@ +/* +# Copyright 2017 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +*/ + +#include <assert.h> +#include <stdint.h> + +#include <gnutls/gnutls.h> +#include <gnutls/ocsp.h> + + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + gnutls_datum_t raw; + gnutls_datum_t out; + gnutls_ocsp_req_t req; + int ret; + + raw.data = (unsigned char *)data; + raw.size = size; + + ret = gnutls_ocsp_req_init(&req); + assert(ret >= 0); + + ret = gnutls_ocsp_req_import(req, &raw); + if (ret >= 0) { + ret = gnutls_ocsp_req_print(req, GNUTLS_OCSP_PRINT_FULL, &out); + assert(ret >= 0); + gnutls_free(out.data); + } + + gnutls_ocsp_req_deinit(req); + return 0; +} diff --git a/devel/fuzz/gnutls_ocsp_resp_parser_fuzzer.cc b/devel/fuzz/gnutls_ocsp_resp_parser_fuzzer.cc new file mode 100644 index 0000000000..5e8657c2cc --- /dev/null +++ b/devel/fuzz/gnutls_ocsp_resp_parser_fuzzer.cc @@ -0,0 +1,47 @@ +/* +# Copyright 2017 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +*/ + +#include <assert.h> +#include <stdint.h> + +#include <gnutls/gnutls.h> +#include <gnutls/ocsp.h> + + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + gnutls_datum_t raw; + gnutls_datum_t out; + gnutls_ocsp_resp_t resp; + int ret; + + raw.data = (unsigned char *)data; + raw.size = size; + + ret = gnutls_ocsp_resp_init(&resp); + assert(ret >= 0); + + ret = gnutls_ocsp_resp_import(resp, &raw); + if (ret >= 0) { + ret = gnutls_ocsp_resp_print(resp, GNUTLS_OCSP_PRINT_FULL, &out); + assert(ret >= 0); + gnutls_free(out.data); + } + + gnutls_ocsp_resp_deinit(resp); + return 0; +} |