Add new fuzzer for the URL parser

* fuzz/Makefile.am: Add wget_url_fuzzer
* fuzz/wget_url_fuzzer.c: New fuzzer
* fuzz/wget_url_fuzzer.in: Initial corpora
This commit is contained in:
Tim Rühsen 2018-04-23 23:03:43 +02:00
parent 93e5a97f25
commit 02325168ca
775 changed files with 814 additions and 1 deletions

View File

@ -13,7 +13,8 @@ WGET_TESTS = \
wget_ftpls_fuzzer$(EXEEXT) \
wget_html_fuzzer$(EXEEXT) \
wget_options_fuzzer$(EXEEXT) \
wget_robots_fuzzer$(EXEEXT)
wget_robots_fuzzer$(EXEEXT) \
wget_url_fuzzer$(EXEEXT)
if FUZZING
bin_PROGRAMS = $(WGET_TESTS)
@ -48,6 +49,9 @@ wget_options_fuzzer_LDADD = ../src/libunittest.a $(LDADD)
wget_robots_fuzzer_SOURCES = wget_robots_fuzzer.c $(MAIN)
wget_robots_fuzzer_LDADD = ../src/libunittest.a $(LDADD)
wget_url_fuzzer_SOURCES = wget_url_fuzzer.c $(MAIN)
wget_url_fuzzer_LDADD = ../src/libunittest.a $(LDADD)
#EXTRA_DIST = $(wildcard *.options) $(wildcard *.dict) \
# $(wildcard *.in) $(wildcard *.repro)

110
fuzz/wget_url_fuzzer.c Normal file
View File

@ -0,0 +1,110 @@
/*
* Copyright(c) 2017-2018 Free Software Foundation, Inc.
*
* This file is part of GNU Wget.
*
* GNU Wget is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GNU Wget 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Wget. If not, see <https://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <sys/types.h>
#include <stdint.h> // uint8_t
#include <stdio.h> // fmemopen
#include <string.h> // strncmp
#include <stdlib.h> // free
#include <unistd.h> // close
#include "wget.h"
#undef fopen_wgetrc
#ifdef __cplusplus
extern "C" {
#endif
#include "url.h"
// declarations for wget internal functions
int main_wget(int argc, const char **argv);
void cleanup(void);
FILE *fopen_wget(const char *pathname, const char *mode);
FILE *fopen_wgetrc(const char *pathname, const char *mode);
void exit_wget(int status);
#ifdef __cplusplus
}
#endif
#include "fuzzer.h"
FILE *fopen_wget(const char *pathname, const char *mode)
{
return fopen("/dev/null", mode);
}
FILE *fopen_wgetrc(const char *pathname, const char *mode)
{
return NULL;
}
#ifdef FUZZING
void exit_wget(int status)
{
}
#else
void exit(int status)
{
}
#endif
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
FILE *bak;
struct url *url;
struct iri iri;
char *in;
if (size > 4096) // same as max_len = ... in .options file
return 0;
bak = stderr;
stderr = fopen("/dev/null", "w");
in = (char *) malloc(size + 1);
memcpy(in, data, size);
in[size] = 0;
iri.uri_encoding = (char *) "iso-8859-1";
iri.orig_url = NULL;
iri.utf8_encode = 0;
url = url_parse(in, NULL, &iri, 0);
url_free(url);
url = url_parse(in, NULL, &iri, 1);
url_free(url);
iri.utf8_encode = 1;
url = url_parse(in, NULL, &iri, 0);
url_free(url);
url = url_parse(in, NULL, &iri, 1);
url_free(url);
free(iri.orig_url);
free(in);
fclose(stderr);
stderr = bak;
return 0;
}

View File

@ -0,0 +1 @@
httpS://ц<><D186><EFBFBD>

View File

@ -0,0 +1 @@
http://aXX

View File

@ -0,0 +1 @@
hxiyelNNFNNNNNCyelNNFº±NNNNN666

View File

@ -0,0 +1 @@
hWWWWWWWWWWW

View File

@ -0,0 +1 @@
Waliaトf

View File

@ -0,0 +1 @@
http://<2F>%<<<<<%<04>

View File

@ -0,0 +1 @@
dddd

View File

@ -0,0 +1 @@
http://a8b@x.yzÌ0/di&&&&&ir/f

View File

@ -0,0 +1 @@
httgtphtgh

View File

@ -0,0 +1 @@
http://a>://a:b@:b@x.y:2%%de««SS.%e§=°¹val'f¡

View File

@ -0,0 +1 @@
ccccccccc/di

View File

@ -0,0 +1 @@
http://iehl

View File

@ -0,0 +1,3 @@
http://http:/¯a:b@x.%%%%%%66%6%66666600000#f
r/3f
r/fval'f

View File

@ -0,0 +1 @@
ftp://[b::]p

View File

@ -0,0 +1 @@
LpJ

View File

@ -0,0 +1 @@
hI22222222222222222222222222222222

View File

@ -0,0 +1 @@
Hhe686>

View File

@ -0,0 +1 @@
hSt5ctypeIcESt5ctypIcE.yz#f

View File

@ -0,0 +1 @@
http://http://a:b@x.yz80/diÂ<69>ÂÂÂ<C382><C382><EFBFBD>%00000000000000000000000000000000...%%%%%%%%%%%%%%%%00000;00000000000000000val&keSSSl'f

View File

@ -0,0 +1 @@
RRf

View File

@ -0,0 +1 @@
http://aェェェttttttttttttttt%%%%%%%%nnnnnnnnnnnnnn

View File

@ -0,0 +1 @@
http://aX%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View File

@ -0,0 +1 @@
http://a:b@

View File

@ -0,0 +1 @@
iQ

View File

@ -0,0 +1 @@
http://<<<<<<<<<<<k

View File

@ -0,0 +1 @@
333232

View File

@ -0,0 +1 @@
http://[0.]

View File

@ -0,0 +1 @@
hF0

View File

@ -0,0 +1 @@
rrrdrrd:

View File

@ -0,0 +1 @@
gBggggggggyyyyyyyyg尨

View File

@ -0,0 +1 @@
hxiek7yel116842684

View File

@ -0,0 +1 @@
http://a8:b@0</dir‰‰‰‰‰‰‰‰‰‰‰‰‰:/1=val

View File

@ -0,0 +1,2 @@
http://http:/:b@ВЌ%%%%%%%Ь%%%%%%%%%%%%%http://aЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄЄ(ЄЄЄЄЄЄЄЄЄ66666667;000000000000В%%%%%%%%%%%%%%%%%%%%%%66666666666666'f
7;000000000000В%%%%%%%%%%%%%%%%%%%%%6%6666666666666'f

View File

@ -0,0 +1 @@
http://a://a:b@x.y:80/di8....../.../.././0/dir/fh

View File

@ -0,0 +1 @@
hxel00000NNNooooÆN66

View File

@ -0,0 +1 @@
htkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk/Fil

View File

@ -0,0 +1 @@
http://[BBB:BBBBB]

View File

@ -0,0 +1 @@
http://acbキャャャャャ;ャb<EFBDAC>キャム<EFBDAC>ャャャャャャャャャャャャャャャ'

View File

@ -0,0 +1 @@
http://ÿee=j

View File

@ -0,0 +1 @@
http://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><15><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>

View File

@ -0,0 +1 @@
3332BBBB

View File

@ -0,0 +1 @@
http://Õ./.0/d//../.......0/d..........0/d//../.......0/di8.....il..e.x?keir/file.x?key=ee=kxval&key2=val#f

View File

@ -0,0 +1 @@
ftp://ホ:%33;

View File

@ -0,0 +1 @@
http://[5555b]

View File

@ -0,0 +1 @@
http://a:b@uŠŠÿÿÿÿÿÿÿ%%%.ŠŠ3=val#f

View File

@ -0,0 +1 @@
hEEEEEEEE

View File

@ -0,0 +1 @@
http://a:bÓ@цÅǶr/f.6

View File

@ -0,0 +1 @@
http://a:b@x.ŠŠŠŠŠŠŠŠŠŠŠŠŠht://../.....<2E>Š..ŠŠŠŠŠŠ

View File

@ -0,0 +1 @@
http://öap://::::::!:::::::::::::Ú:::˙˙˙˙::::.ebbbbbb&key2=val#f

View File

@ -0,0 +1 @@
hIIII7777777777777777777777777777777777777777777777777htQQQQQQQQ#f

View File

@ -0,0 +1 @@
http://a<>:b@x.<2E><> <0A><><EFBFBD><EFBFBD><EFBFBD>%%

View File

@ -0,0 +1 @@
http://[%301.]

View File

@ -0,0 +1 @@
http://a:b@x%%%%<<<<<k 1=val#f

View File

@ -0,0 +1 @@
OO

View File

@ -0,0 +1 @@
Kbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb郹<13>

View File

@ -0,0 +1 @@
http://h/

View File

@ -0,0 +1 @@
http://<18>

View File

@ -0,0 +1 @@
http://[%33::]ス

View File

@ -0,0 +1 @@
http://a:b@xal&k\\\\\\\\\\\\\\\\\\\¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾\\\\\\\\ey2http://a:bx@.yz80/di80/dhttp://ap:)//a:b@x.y:80

View File

@ -0,0 +1 @@
ftp://<2F>;

View File

@ -0,0 +1 @@
http://ape~~)eeeeeeeee%eeeeege

View File

@ -0,0 +1 @@
httpS://.

View File

@ -0,0 +1 @@
http://a:/............/.././...../.././....dir=

View File

@ -0,0 +1 @@
Hh

View File

@ -0,0 +1 @@
ftp://%3a:%32

View File

@ -0,0 +1 @@
Irzrrrrrz」tp:/ャャ;

View File

@ -0,0 +1 @@
ww

View File

@ -0,0 +1 @@
hMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy0=

View File

@ -0,0 +1 @@
ht6666000000000000000000060000000000000106:2341val#f

View File

@ -0,0 +1 @@
4<EFBFBD>

View File

@ -0,0 +1 @@
hTtTt

View File

@ -0,0 +1 @@
htklLllllllli

View File

@ -0,0 +1 @@
http://httpyyyyyyyy˙:0000000000000000000000000000000000

View File

@ -0,0 +1 @@
http://key=vax

View File

@ -0,0 +1 @@
http://ム末末;蘭

View File

@ -0,0 +1 @@
http://a:b@=val#ÿÿÿÿy3=va:l#ÿÿÿÿf

View File

@ -0,0 +1 @@
hVmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmml

View File

@ -0,0 +1 @@
77777777III#f

View File

@ -0,0 +1 @@
httKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKp:/q#f

View File

@ -0,0 +1 @@
httLLxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx#f

View File

@ -0,0 +1 @@
http://ÿÿÿÿpa:960/al

View File

@ -0,0 +1 @@
http://%3a

View File

@ -0,0 +1,2 @@
http://a:b@x.yz80ÈÇÏÐìf
r/file.x?key=val&key2=va:l#f

Some files were not shown because too many files have changed in this diff Show More