]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
fuzz: added OCSP structure parsers
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Wed, 8 Mar 2017 16:01:59 +0000 (17:01 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 9 Mar 2017 12:22:38 +0000 (13:22 +0100)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
devel/fuzz/Makefile
devel/fuzz/gnutls_ocsp_req_parser_fuzzer.cc [new file with mode: 0644]
devel/fuzz/gnutls_ocsp_resp_parser_fuzzer.cc [new file with mode: 0644]

index d45fc7bd574029dbc5c0d5c897ba0600d304534a..dfdbc9c7658bab2131323c0418eae16889fdd5c7 100644 (file)
@@ -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 (file)
index 0000000..af99056
--- /dev/null
@@ -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 (file)
index 0000000..5e8657c
--- /dev/null
@@ -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;
+}