summaryrefslogtreecommitdiff
path: root/devel
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-08-11 11:09:39 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-08-11 11:10:44 +0200
commit47d5403fb9f4b6f877d64dbbf8e1b851e4a49927 (patch)
tree567fb0ecc4561f21888ce2824b2fc40433f5bd22 /devel
parent81d3205d1567e5a0d694085653e51abdb461864b (diff)
downloadgnutls-47d5403fb9f4b6f877d64dbbf8e1b851e4a49927.tar.gz
fuzz: explicitly initialize and deinitialize the library [ci skip]
This enables the fuzzers to run even when statically linked. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'devel')
-rw-r--r--devel/fuzz/gnutls_client_fuzzer.cc3
-rw-r--r--devel/fuzz/gnutls_dn_parser_fuzzer.cc3
-rw-r--r--devel/fuzz/gnutls_ocsp_req_parser_fuzzer.cc3
-rw-r--r--devel/fuzz/gnutls_ocsp_resp_parser_fuzzer.cc3
-rw-r--r--devel/fuzz/gnutls_pkcs12_key_parser_fuzzer.cc3
-rw-r--r--devel/fuzz/gnutls_pkcs7_parser_fuzzer.cc3
-rw-r--r--devel/fuzz/gnutls_pkcs8_key_parser_fuzzer.cc3
-rw-r--r--devel/fuzz/gnutls_private_key_parser_fuzzer.cc3
-rw-r--r--devel/fuzz/gnutls_psk_client_fuzzer.cc4
-rw-r--r--devel/fuzz/gnutls_psk_server_fuzzer.cc4
-rw-r--r--devel/fuzz/gnutls_server_fuzzer.cc3
-rw-r--r--devel/fuzz/gnutls_srp_client_fuzzer.cc3
-rw-r--r--devel/fuzz/gnutls_srp_server_fuzzer.cc3
-rw-r--r--devel/fuzz/gnutls_x509_parser_fuzzer.cc3
14 files changed, 44 insertions, 0 deletions
diff --git a/devel/fuzz/gnutls_client_fuzzer.cc b/devel/fuzz/gnutls_client_fuzzer.cc
index b9c22200e6..4c598541f2 100644
--- a/devel/fuzz/gnutls_client_fuzzer.cc
+++ b/devel/fuzz/gnutls_client_fuzzer.cc
@@ -38,6 +38,8 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
gnutls_certificate_credentials_t xcred;
struct mem_st memdata;
+ gnutls_global_init();
+
res = gnutls_init(&session, GNUTLS_CLIENT);
assert(res >= 0);
@@ -73,5 +75,6 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
gnutls_deinit(session);
gnutls_certificate_free_credentials(xcred);
+ gnutls_global_deinit();
return 0;
}
diff --git a/devel/fuzz/gnutls_dn_parser_fuzzer.cc b/devel/fuzz/gnutls_dn_parser_fuzzer.cc
index 24f76a54c6..e493a53ccf 100644
--- a/devel/fuzz/gnutls_dn_parser_fuzzer.cc
+++ b/devel/fuzz/gnutls_dn_parser_fuzzer.cc
@@ -28,6 +28,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
gnutls_x509_dn_t dn;
int ret;
+ gnutls_global_init();
+
raw.data = (unsigned char *)data;
raw.size = size;
@@ -48,5 +50,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
cleanup:
gnutls_x509_dn_deinit(dn);
+ gnutls_global_deinit();
return 0;
}
diff --git a/devel/fuzz/gnutls_ocsp_req_parser_fuzzer.cc b/devel/fuzz/gnutls_ocsp_req_parser_fuzzer.cc
index af99056158..4cc0612cc4 100644
--- a/devel/fuzz/gnutls_ocsp_req_parser_fuzzer.cc
+++ b/devel/fuzz/gnutls_ocsp_req_parser_fuzzer.cc
@@ -29,6 +29,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
gnutls_ocsp_req_t req;
int ret;
+ gnutls_global_init();
+
raw.data = (unsigned char *)data;
raw.size = size;
@@ -43,5 +45,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
gnutls_ocsp_req_deinit(req);
+ gnutls_global_deinit();
return 0;
}
diff --git a/devel/fuzz/gnutls_ocsp_resp_parser_fuzzer.cc b/devel/fuzz/gnutls_ocsp_resp_parser_fuzzer.cc
index 1e7b8a0857..4027d61881 100644
--- a/devel/fuzz/gnutls_ocsp_resp_parser_fuzzer.cc
+++ b/devel/fuzz/gnutls_ocsp_resp_parser_fuzzer.cc
@@ -31,6 +31,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
gnutls_ocsp_resp_t resp;
int ret;
+ gnutls_global_init();
+
raw.data = (unsigned char *)data;
raw.size = size;
@@ -45,5 +47,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
gnutls_ocsp_resp_deinit(resp);
+ gnutls_global_deinit();
return 0;
}
diff --git a/devel/fuzz/gnutls_pkcs12_key_parser_fuzzer.cc b/devel/fuzz/gnutls_pkcs12_key_parser_fuzzer.cc
index 84f1ddb153..f44e47fb37 100644
--- a/devel/fuzz/gnutls_pkcs12_key_parser_fuzzer.cc
+++ b/devel/fuzz/gnutls_pkcs12_key_parser_fuzzer.cc
@@ -34,6 +34,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
unsigned int i;
int ret;
+ gnutls_global_init();
+
raw.data = (unsigned char *)data;
raw.size = size;
@@ -67,5 +69,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
cleanup:
gnutls_pkcs12_deinit(p12);
+ gnutls_global_deinit();
return 0;
}
diff --git a/devel/fuzz/gnutls_pkcs7_parser_fuzzer.cc b/devel/fuzz/gnutls_pkcs7_parser_fuzzer.cc
index f6f9948d4b..ffdb30134f 100644
--- a/devel/fuzz/gnutls_pkcs7_parser_fuzzer.cc
+++ b/devel/fuzz/gnutls_pkcs7_parser_fuzzer.cc
@@ -29,6 +29,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
gnutls_pkcs7_t pkcs7;
int ret;
+ gnutls_global_init();
+
raw.data = (unsigned char *)data;
raw.size = size;
@@ -43,5 +45,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
gnutls_pkcs7_deinit(pkcs7);
+ gnutls_global_deinit();
return 0;
}
diff --git a/devel/fuzz/gnutls_pkcs8_key_parser_fuzzer.cc b/devel/fuzz/gnutls_pkcs8_key_parser_fuzzer.cc
index 2aed9def60..00e6548dc7 100644
--- a/devel/fuzz/gnutls_pkcs8_key_parser_fuzzer.cc
+++ b/devel/fuzz/gnutls_pkcs8_key_parser_fuzzer.cc
@@ -29,6 +29,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
gnutls_datum_t out;
int ret;
+ gnutls_global_init();
+
raw.data = (unsigned char *)data;
raw.size = size;
@@ -50,5 +52,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
cleanup:
gnutls_x509_privkey_deinit(key);
+ gnutls_global_deinit();
return 0;
}
diff --git a/devel/fuzz/gnutls_private_key_parser_fuzzer.cc b/devel/fuzz/gnutls_private_key_parser_fuzzer.cc
index 63d8163fa7..51b92474ab 100644
--- a/devel/fuzz/gnutls_private_key_parser_fuzzer.cc
+++ b/devel/fuzz/gnutls_private_key_parser_fuzzer.cc
@@ -28,6 +28,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
gnutls_x509_privkey_t key;
int ret;
+ gnutls_global_init();
+
raw.data = (unsigned char *)data;
raw.size = size;
@@ -37,5 +39,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
ret = gnutls_x509_privkey_import(key, &raw, GNUTLS_X509_FMT_DER);
gnutls_x509_privkey_deinit(key);
+ gnutls_global_deinit();
return 0;
}
diff --git a/devel/fuzz/gnutls_psk_client_fuzzer.cc b/devel/fuzz/gnutls_psk_client_fuzzer.cc
index 0d622dcf8e..6cbe26924b 100644
--- a/devel/fuzz/gnutls_psk_client_fuzzer.cc
+++ b/devel/fuzz/gnutls_psk_client_fuzzer.cc
@@ -45,6 +45,8 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
struct mem_st memdata;
gnutls_datum_t psk_key;
+ gnutls_global_init();
+
psk_key.data = (unsigned char*)psk_key16;
psk_key.size = 16;
@@ -87,5 +89,7 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
gnutls_deinit(session);
gnutls_psk_free_client_credentials(pcred);
+
+ gnutls_global_deinit();
return 0;
}
diff --git a/devel/fuzz/gnutls_psk_server_fuzzer.cc b/devel/fuzz/gnutls_psk_server_fuzzer.cc
index dcbbba6640..99ec4e34cc 100644
--- a/devel/fuzz/gnutls_psk_server_fuzzer.cc
+++ b/devel/fuzz/gnutls_psk_server_fuzzer.cc
@@ -60,6 +60,8 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
gnutls_psk_server_credentials_t pcred;
struct mem_st memdata;
+ gnutls_global_init();
+
res = gnutls_init(&session, GNUTLS_SERVER);
assert(res >= 0);
@@ -137,5 +139,7 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
gnutls_deinit(session);
gnutls_certificate_free_credentials(xcred);
gnutls_psk_free_server_credentials(pcred);
+
+ gnutls_global_deinit();
return 0;
}
diff --git a/devel/fuzz/gnutls_server_fuzzer.cc b/devel/fuzz/gnutls_server_fuzzer.cc
index ef2176af16..d9a4bb5d21 100644
--- a/devel/fuzz/gnutls_server_fuzzer.cc
+++ b/devel/fuzz/gnutls_server_fuzzer.cc
@@ -40,6 +40,8 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
gnutls_certificate_credentials_t xcred;
struct mem_st memdata;
+ gnutls_global_init();
+
res = gnutls_init(&session, GNUTLS_SERVER);
assert(res >= 0);
@@ -107,5 +109,6 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
gnutls_deinit(session);
gnutls_certificate_free_credentials(xcred);
+ gnutls_global_deinit();
return 0;
}
diff --git a/devel/fuzz/gnutls_srp_client_fuzzer.cc b/devel/fuzz/gnutls_srp_client_fuzzer.cc
index c1923605a8..aecf753b1f 100644
--- a/devel/fuzz/gnutls_srp_client_fuzzer.cc
+++ b/devel/fuzz/gnutls_srp_client_fuzzer.cc
@@ -44,6 +44,8 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
gnutls_srp_client_credentials_t pcred;
struct mem_st memdata;
+ gnutls_global_init();
+
res = gnutls_init(&session, GNUTLS_CLIENT);
assert(res >= 0);
@@ -83,5 +85,6 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
gnutls_deinit(session);
gnutls_srp_free_client_credentials(pcred);
+ gnutls_global_deinit();
return 0;
}
diff --git a/devel/fuzz/gnutls_srp_server_fuzzer.cc b/devel/fuzz/gnutls_srp_server_fuzzer.cc
index 95db8c34a1..caafd34c0c 100644
--- a/devel/fuzz/gnutls_srp_server_fuzzer.cc
+++ b/devel/fuzz/gnutls_srp_server_fuzzer.cc
@@ -72,6 +72,8 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
gnutls_srp_server_credentials_t pcred;
struct mem_st memdata;
+ gnutls_global_init();
+
res = gnutls_init(&session, GNUTLS_SERVER);
assert(res >= 0);
@@ -148,5 +150,6 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
gnutls_deinit(session);
gnutls_certificate_free_credentials(xcred);
gnutls_srp_free_server_credentials(pcred);
+ gnutls_global_deinit();
return 0;
}
diff --git a/devel/fuzz/gnutls_x509_parser_fuzzer.cc b/devel/fuzz/gnutls_x509_parser_fuzzer.cc
index 28dc3397fc..31eecca859 100644
--- a/devel/fuzz/gnutls_x509_parser_fuzzer.cc
+++ b/devel/fuzz/gnutls_x509_parser_fuzzer.cc
@@ -29,6 +29,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
gnutls_x509_crt_t crt;
int ret;
+ gnutls_global_init();
+
raw.data = (unsigned char *)data;
raw.size = size;
@@ -43,5 +45,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
gnutls_x509_crt_deinit(crt);
+ gnutls_global_deinit();
return 0;
}