diff --git a/configure.ac b/configure.ac index 9416e9ebb..87ddf1cbc 100644 --- a/configure.ac +++ b/configure.ac @@ -134,7 +134,9 @@ if test -n "$WARN_CFLAGS"; then wget_WORD_REMOVE([WARN_CFLAGS], [$WARN_CFLAGS], [$nw]) # add more flags as you like - WARN_CFLAGS="$WARN_CFLAGS -fdiagnostics-color=always" + if test $GCC_VERSION -ge 5; then + WARN_CFLAGS="$WARN_CFLAGS -fdiagnostics-color=always" + fi if test "$cross_compiling" = yes; then WARN_CFLAGS="$WARN_CFLAGS -Wno-format" fi diff --git a/fuzz/Makefile.am b/fuzz/Makefile.am index d2a818cc7..4f35f38f6 100644 --- a/fuzz/Makefile.am +++ b/fuzz/Makefile.am @@ -14,6 +14,7 @@ WGET_TESTS = \ libwget_base64_fuzzer$(EXEEXT) \ libwget_cookie_fuzzer$(EXEEXT) \ libwget_css_url_fuzzer$(EXEEXT) \ + libwget_html_url_fuzzer$(EXEEXT) \ libwget_iri_fuzzer$(EXEEXT) \ libwget_metalink_parse_fuzzer$(EXEEXT) \ libwget_robots_parse_fuzzer$(EXEEXT) \ @@ -28,6 +29,7 @@ libwget_bar_fuzzer_SOURCES = libwget_bar_fuzzer.c main.c fuzzer.h libwget_base64_fuzzer_SOURCES = libwget_base64_fuzzer.c main.c fuzzer.h libwget_cookie_fuzzer_SOURCES = libwget_cookie_fuzzer.c main.c fuzzer.h libwget_css_url_fuzzer_SOURCES = libwget_css_url_fuzzer.c main.c fuzzer.h +libwget_html_url_fuzzer_SOURCES = libwget_html_url_fuzzer.c main.c fuzzer.h libwget_iri_fuzzer_SOURCES = libwget_iri_fuzzer.c main.c fuzzer.h libwget_metalink_parse_fuzzer_SOURCES = libwget_metalink_parse_fuzzer.c main.c fuzzer.h libwget_robots_parse_fuzzer_SOURCES = libwget_robots_parse_fuzzer.c main.c fuzzer.h diff --git a/fuzz/libwget_html_url_fuzzer.c b/fuzz/libwget_html_url_fuzzer.c new file mode 100644 index 000000000..1621d9b9e --- /dev/null +++ b/fuzz/libwget_html_url_fuzzer.c @@ -0,0 +1,49 @@ +/* + * Copyright(c) 2017 Free Software Foundation, Inc. + * + * This file is part of libwget. + * + * Libwget 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 3 of the License, or + * (at your option) any later version. + * + * Libwget 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 libwget. If not, see . + */ + +#include + +#include +#include +#include +#include +#include + +#include "wget.h" +#include "fuzzer.h" + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + if (size > 10000) // same as max_len = 10000 in .options file + return 0; + + char *in = (char *) malloc(size + 2); + assert(in != NULL); + + // 0 terminate + memcpy(in, data, size); + in[size] = in[size + 1] = 0; + + WGET_HTML_PARSED_RESULT *res = wget_html_get_urls_inline(in, NULL, NULL); + wget_html_free_urls_inline(&res); + + free(in); + + return 0; +} diff --git a/fuzz/libwget_html_url_fuzzer.dict b/fuzz/libwget_html_url_fuzzer.dict new file mode 100644 index 000000000..b56efc081 --- /dev/null +++ b/fuzz/libwget_html_url_fuzzer.dict @@ -0,0 +1,22 @@ +"ou +

iteu<c +

iteu<c +omeuou +

iteu<c +

iteu<c +omeu + +emou< +ou< +em +emou< +emou< +ou< +em +emou< +ou< +ememm>iteu<iteu<ou< +ememm>iteu<iteu<1*c(e>(>( \ No newline at end of file diff --git a/fuzz/libwget_html_url_fuzzer.in/09836403ed571416fae7f4c6d92d70fd59bb0f00 b/fuzz/libwget_html_url_fuzzer.in/09836403ed571416fae7f4c6d92d70fd59bb0f00 new file mode 100644 index 000000000..a8aaa5bee --- /dev/null +++ b/fuzz/libwget_html_url_fuzzer.in/09836403ed571416fae7f4c6d92d70fd59bb0f00 @@ -0,0 +1,25 @@ + + +============ +===souemont>sou +===souemou< +===souemo==================================souemou< +===souemo===souemont>sou +===souemou< +===souemo===souemont>sou + +===souemou< +===souemou~ +l........======================================================================================souemou< +......,...................1y<.tl +s.e>.....................................3..........................l........l.................................................3.. +