Commit 9a6e460f authored by Tim Rühsen's avatar Tim Rühsen 🛠

Add libidn2_register_fuzzer and corpora

parent ed99aa8c
......@@ -6,12 +6,14 @@ LDADD = ../lib/libidn2.la ../gl/libgnu.la $(LTLIBUNISTRING)
IDN_TESTS = \
libidn2_to_ascii_8z_fuzzer$(EXEEXT) \
libidn2_to_unicode_8z8z_fuzzer$(EXEEXT)
libidn2_to_unicode_8z8z_fuzzer$(EXEEXT) \
libidn2_register_fuzzer$(EXEEXT)
check_PROGRAMS = $(IDN_TESTS)
libidn2_to_ascii_8z_fuzzer_SOURCES = libidn2_to_ascii_8z_fuzzer.c main.c fuzzer.h
libidn2_to_unicode_8z8z_fuzzer_SOURCES = libidn2_to_unicode_8z8z_fuzzer.c main.c fuzzer.h
libidn2_register_fuzzer_SOURCES = libidn2_register_fuzzer.c main.c fuzzer.h
dist-hook:
find . -name '*.options' -exec cp -v '{}' $(distdir) ';'
......
/*
* Copyright(c) 2019 Tim Ruehsen
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* This file is part of libidn2.
*/
#include <config.h>
#include <assert.h> /* assert */
#include <stdlib.h> /* malloc, free */
#include <string.h> /* memcpy */
#include "idn2.h"
#include "fuzzer.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
char *ulabel, *alabel;
char *out;
if (size > 1024)
return 0;
ulabel = (char *) malloc(size + 1);
assert(ulabel != NULL);
/* 0 terminate */
memcpy(ulabel, data, size);
ulabel[size] = 0;
if (idn2_register_ul(ulabel, NULL, &out, 0) == IDNA_SUCCESS)
idn2_free(out);
free(ulabel);
alabel = (char *) malloc(size + 4 + 1);
assert(alabel != NULL);
/* 0 terminate */
memcpy(alabel, "xn--", 4);
memcpy(alabel + 4, data, size);
alabel[size] = 0;
if (idn2_register_ul(NULL, alabel, &out, 0) == IDNA_SUCCESS)
idn2_free(out);
free(alabel);
return 0;
}
fbKvNAAAAAAAaAAAAAAAAADN
\ No newline at end of file
fDKN9DKy4fbafaaaaaaaaaaaaafa
\ No newline at end of file
YhbKHnAAAACAbECbAaEEME
\ No newline at end of file
YhbKnAAAAAAAAAAAAAAAEEEEjEEE
\ No newline at end of file
xn--mkv9vvv3vvvvvxn--vvvvvvv8vv9vvDvD
\ No newline at end of file
jjbbjKjjjjKjZZZZZZZZZZZZZZZZZZZZZZjZZjj
\ No newline at end of file
YhbYhbKnAAAAAAAAAAAAAAAAEEE
\ No newline at end of file
bmbkbbbbbVbbbbbbbbbbbbbbbbbabbbbbbbbbbb
\ No newline at end of file
xnwlwjwwwwmwwwwjwwww}T
\ No newline at end of file
jjbjxn---jbkj4xxxxxxxUxxxxxxxhjjjxx7xffFfj
\ No newline at end of file
fffffffffffffffffffffffflffffffff')*
\ No newline at end of file
jvvtvvvvvvxvvvvvxvn--xxn--xn--fNSt6locaaaaaaa!fj
\ No newline at end of file
YhbKnGAAAAAAAAAAAAAAAAEEEEE
\ No newline at end of file
YhbKnKlAAAAAAAAAAAAAAAAEEE
\ No newline at end of file
bmbekbbbbbbbbbbbYbbbbbbbbbbbbbbbbbbbb
\ No newline at end of file
xfxn7xXXXXn7xXXXXXXXXXmmmmmmmxmmvmmmmmmmmmmnmmm-
\ No newline at end of file
------------------------D-------------------<,
\ No newline at end of file
fDKN9DIyy4faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaf*
\ No newline at end of file
jvvvvvvvvvxn--xn-bbKjj
\ No newline at end of file
jnWWWWWzzzzzzzzzzzzzzzzzzzzzzzzzzzWWW
\ No newline at end of file