diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2017-01-24 13:50:59 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-01-26 15:42:14 +0100 |
commit | e77eb65a661d6d524cdbf64843022723f55769a9 (patch) | |
tree | 2b5eab7d484ad4318e20ff557015a960d642d4e3 | |
parent | 783f40956975973439e048056049cc47c0084273 (diff) | |
download | gnutls-e77eb65a661d6d524cdbf64843022723f55769a9.tar.gz |
fuzz: Added IDNA encoding/decoding fuzzying units
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | devel/fuzz/Makefile | 9 | ||||
-rw-r--r-- | devel/fuzz/gnutls_idna_parser.in/dns1 | 1 | ||||
-rw-r--r-- | devel/fuzz/gnutls_idna_parser.in/dns2 | 1 | ||||
-rw-r--r-- | devel/fuzz/gnutls_idna_parser.in/dns3 | 1 | ||||
-rw-r--r-- | devel/fuzz/gnutls_idna_parser.in/dns4 | 1 | ||||
-rw-r--r-- | devel/fuzz/gnutls_idna_parser_fuzzer.cc | 39 | ||||
-rw-r--r-- | devel/fuzz/gnutls_reverse_idna_parser.in/ace1 | 1 | ||||
-rw-r--r-- | devel/fuzz/gnutls_reverse_idna_parser.in/ace2 | 1 | ||||
-rw-r--r-- | devel/fuzz/gnutls_reverse_idna_parser.in/ace3 | 1 | ||||
-rw-r--r-- | devel/fuzz/gnutls_reverse_idna_parser_fuzzer.cc | 39 | ||||
-rw-r--r-- | devel/fuzz/main.c | 44 |
12 files changed, 138 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore index 97a353b514..6ce7207157 100644 --- a/.gitignore +++ b/.gitignore @@ -205,6 +205,7 @@ doc/tpm-api.texi doc/version-guile.texi doc/version.texi doc/x509-api.texi +devel/fuzz/gnutls_*_fuzzer extra/Makefile extra/Makefile.in extra/includes/Makefile diff --git a/devel/fuzz/Makefile b/devel/fuzz/Makefile index fc9d95c55c..8e83dd12a8 100644 --- a/devel/fuzz/Makefile +++ b/devel/fuzz/Makefile @@ -48,7 +48,14 @@ gnutls_server_fuzzer: gnutls_server_fuzzer.cc gnutls_x509_parser_fuzzer: gnutls_x509_parser_fuzzer.cc $(CC) $(CFLAGS) main.c $^ $(COMMON) -o $@ +gnutls_idna_parser_fuzzer: gnutls_idna_parser_fuzzer.cc + $(CC) $(CFLAGS) main.c $^ $(COMMON) -o $@ + +gnutls_reverse_idna_parser_fuzzer: gnutls_reverse_idna_parser_fuzzer.cc + $(CC) $(CFLAGS) main.c $^ $(COMMON) -o $@ + 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_private_key_parser_fuzzer gnutls_server_fuzzer gnutls_x509_parser_fuzzer \ + gnutls_idna_parser_fuzzer gnutls_reverse_idna_parser_fuzzer diff --git a/devel/fuzz/gnutls_idna_parser.in/dns1 b/devel/fuzz/gnutls_idna_parser.in/dns1 new file mode 100644 index 0000000000..13ce7f21d1 --- /dev/null +++ b/devel/fuzz/gnutls_idna_parser.in/dns1 @@ -0,0 +1 @@ +LOCALHOST diff --git a/devel/fuzz/gnutls_idna_parser.in/dns2 b/devel/fuzz/gnutls_idna_parser.in/dns2 new file mode 100644 index 0000000000..7fed584a6e --- /dev/null +++ b/devel/fuzz/gnutls_idna_parser.in/dns2 @@ -0,0 +1 @@ +bücher.de diff --git a/devel/fuzz/gnutls_idna_parser.in/dns3 b/devel/fuzz/gnutls_idna_parser.in/dns3 new file mode 100644 index 0000000000..30babe3601 --- /dev/null +++ b/devel/fuzz/gnutls_idna_parser.in/dns3 @@ -0,0 +1 @@ +日本語.jp diff --git a/devel/fuzz/gnutls_idna_parser.in/dns4 b/devel/fuzz/gnutls_idna_parser.in/dns4 new file mode 100644 index 0000000000..c08920141f --- /dev/null +++ b/devel/fuzz/gnutls_idna_parser.in/dns4 @@ -0,0 +1 @@ +简体中文.εξτρα.com diff --git a/devel/fuzz/gnutls_idna_parser_fuzzer.cc b/devel/fuzz/gnutls_idna_parser_fuzzer.cc new file mode 100644 index 0000000000..06e89b8a36 --- /dev/null +++ b/devel/fuzz/gnutls_idna_parser_fuzzer.cc @@ -0,0 +1,39 @@ +/* +# Copyright 2016 Nikos Mavrogiannopoulos +# +# 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 <stdio.h> +#include <stdint.h> + +#include <gnutls/gnutls.h> + + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + gnutls_datum_t out; + int ret; + + ret = gnutls_idna_map((const char*)data, size, &out, 0); + if (ret < 0) + goto cleanup; + + printf("%s\n", (char*)out.data); + gnutls_free(out.data); + + cleanup: + return 0; +} diff --git a/devel/fuzz/gnutls_reverse_idna_parser.in/ace1 b/devel/fuzz/gnutls_reverse_idna_parser.in/ace1 new file mode 100644 index 0000000000..64b6119730 --- /dev/null +++ b/devel/fuzz/gnutls_reverse_idna_parser.in/ace1 @@ -0,0 +1 @@ +xn--fa-hia.de diff --git a/devel/fuzz/gnutls_reverse_idna_parser.in/ace2 b/devel/fuzz/gnutls_reverse_idna_parser.in/ace2 new file mode 100644 index 0000000000..a42c184210 --- /dev/null +++ b/devel/fuzz/gnutls_reverse_idna_parser.in/ace2 @@ -0,0 +1 @@ +xn--fiqu1az03c18t.xn--mxah1amo.com diff --git a/devel/fuzz/gnutls_reverse_idna_parser.in/ace3 b/devel/fuzz/gnutls_reverse_idna_parser.in/ace3 new file mode 100644 index 0000000000..13ce7f21d1 --- /dev/null +++ b/devel/fuzz/gnutls_reverse_idna_parser.in/ace3 @@ -0,0 +1 @@ +LOCALHOST diff --git a/devel/fuzz/gnutls_reverse_idna_parser_fuzzer.cc b/devel/fuzz/gnutls_reverse_idna_parser_fuzzer.cc new file mode 100644 index 0000000000..1b0a398e02 --- /dev/null +++ b/devel/fuzz/gnutls_reverse_idna_parser_fuzzer.cc @@ -0,0 +1,39 @@ +/* +# Copyright 2016 Nikos Mavrogiannopoulos +# +# 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 <stdio.h> +#include <stdint.h> + +#include <gnutls/gnutls.h> + + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + gnutls_datum_t out; + int ret; + + ret = gnutls_idna_reverse_map((char*)data, size, &out, 0); + if (ret < 0) + goto cleanup; + + printf("%s\n", (char*)out.data); + gnutls_free(out.data); + + cleanup: + return 0; +} diff --git a/devel/fuzz/main.c b/devel/fuzz/main.c new file mode 100644 index 0000000000..602943014c --- /dev/null +++ b/devel/fuzz/main.c @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2017 Nikos Mavrogiannopoulos + * + * Author: Nikos Mavrogiannopoulos + * + * This file is part of GnuTLS. + * + * The GnuTLS is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); + +int main(int argc, char **argv) +{ + int ret; + unsigned char buf[64*1024]; + + ret = fread(buf, 1, sizeof(buf), stdin); + if (ret <= 0) + return 0; + + return LLVMFuzzerTestOneInput(buf, ret); +} |