Add new fuzzer for the .netrc parser

* fuzz/wget_netrc_fuzzer.c: New fuzzer
* fuzz/wget_netrc_fuzzer.dict: Fuzzer dictionary
* fuzz/wget_netrc_fuzzer.in: Initial corpora
* src/ftp.c (getftp): Amend call to search_netrc()
* src/http.c (initialize_request): Likewise
* src/netrc.c: Cleanup, prepare code for fuzzing
* src/netrc.h: Cleanup
This commit is contained in:
Tim Rühsen 2018-04-28 20:03:18 +02:00
parent 734d0aee15
commit a1c9018797
309 changed files with 6733 additions and 40 deletions

View File

@ -13,6 +13,7 @@ WGET_TESTS = \
wget_cookie_fuzzer$(EXEEXT) \
wget_ftpls_fuzzer$(EXEEXT) \
wget_html_fuzzer$(EXEEXT) \
wget_netrc_fuzzer$(EXEEXT) \
wget_options_fuzzer$(EXEEXT) \
wget_robots_fuzzer$(EXEEXT) \
wget_url_fuzzer$(EXEEXT)
@ -47,6 +48,9 @@ wget_ftpls_fuzzer_LDADD = ../src/libunittest.a $(LDADD)
wget_html_fuzzer_SOURCES = wget_html_fuzzer.c $(MAIN)
wget_html_fuzzer_LDADD = ../src/libunittest.a $(LDADD)
wget_netrc_fuzzer_SOURCES = wget_netrc_fuzzer.c $(MAIN)
wget_netrc_fuzzer_LDADD = ../src/libunittest.a $(LDADD)
wget_options_fuzzer_SOURCES = wget_options_fuzzer.c $(MAIN)
wget_options_fuzzer_LDADD = ../src/libunittest.a $(LDADD)

100
fuzz/wget_netrc_fuzzer.c Normal file
View File

@ -0,0 +1,100 @@
/*
* 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 <setjmp.h> // longjmp, setjmp
#include "wget.h"
#undef fopen_wgetrc
#ifdef __cplusplus
extern "C" {
#endif
#include "netrc.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 *fp, *bak;
struct fileinfo *fi;
const char *user = NULL, *pw = NULL;
if (size > 4096) // same as max_len = ... in .options file
return 0;
bak = stderr;
stderr = fopen("/dev/null", "w");
fp = fmemopen((void *) data, size, "r");
if (!fp) return 0;
opt.netrc = 1;
user = NULL; // get first entry
search_netrc("x", &user, &pw, 1, fp);
netrc_cleanup();
user = "u"; // get entry for user 'u'
search_netrc("x", &user, &pw, 1, fp);
netrc_cleanup();
fclose(fp);
fclose(stderr);
stderr = bak;
return 0;
}

View File

@ -0,0 +1,8 @@
"machine"
"default"
"login"
"password"
"macdef"
"account"
"port"
"force"

View File

@ -0,0 +1,4 @@
default force G
force G
fo G
force G

View File

@ -0,0 +1,3 @@
machine
force ye
force ye force ye

View File

@ -0,0 +1,8 @@
dehinen
login
login
login
login
login
login

View File

@ -0,0 +1 @@
"oGÿ"eorne

View File

@ -0,0 +1,3 @@
"defÿÿÿJò
!e)G
a

View File

@ -0,0 +1,13 @@
machine
force Ye force Ye
force Ye
force Ye
force Ye
force Ye force Ye force Ye
force Ye
force Ye
force Ye
force Ye
force Ye
force Ye
force Ye force Ye

View File

@ -0,0 +1,40 @@
default
!
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login

View File

@ -0,0 +1,61 @@
e
a
c
n
c
a
c a
c
c
n
c
a
c
n
a
c
û
n
c e
a
c
n
c
a
c a
c
c
n
c
a
c
n
a
c
û
n
c
a
a
c
û
n
c
a
c
n
a
c
a
a
c
û
n
c
a
c
n
a
c
û
n

View File

@ -0,0 +1,2 @@
def\\\\\\\\\\\\\ÿ
port

View File

@ -0,0 +1,17 @@
machine
efault
login
machn
machine :ogn
login
mwopax
machine a.b
login b
pass÷ord x
machine a.baogiÿe
lt
login b
lologin cßz

View File

@ -0,0 +1,9 @@
#e x.y login y¯password x
#þÿÿÿÿÿÿÿ
machine xûn y password x
#
machine x.e x.y login y passwor#
machine x.e x.y login y¯password x
#þÿÿÿÿÿÿÿ
machine xûû
logyn bûûûûû

View File

@ -0,0 +1,7 @@
#
machine x.y login y password x
#
mx
#
machine (.y login y password x
machine a.bmaûûûûûn"bûûûûû

View File

@ -0,0 +1,2 @@
default force T
force

View File

@ -0,0 +1,17 @@
<EFBFBD>
mc
c
<EFBFBD>
r
mc
c
<EFBFBD>
r
c
c
c
c
<EFBFBD>
m
c
c

View File

@ -0,0 +1,5 @@
#
maûûûûûûûûûûûûûûûûûûûûûûûûûûû
c1 a
c2 z

View File

@ -0,0 +1,5 @@
#
machine def login y passw
c1 a
c2 z

View File

@ -0,0 +1,16 @@
machine
machine
machine
machine
machine
machine
machine
machine
machine
machine
machine
machine
machine
machine
machine
machine

View File

@ -0,0 +1,8 @@
machine
machine m machine »
machine !
machine f
machine * machine xo default machine u
machine x
machine y
machine û

View File

@ -0,0 +1,73 @@
defaupasslogint force T
forcey
m!chine
password
password
password
passworsword
password
password
password
password
password
pa(sword
password
password
password
password
password
password
password
password
password
paspassword
password
password
password
password
password
pa
password
password
passwod
password
password
pa(sword
password
password
password
password
password
password
password
password
password
pcspmachineassword
password
p(sword
password
password
password
passwod
password
password
pa(sword
password
password
password
password
password
password
password
password
password
pcspmachineassword
password
password
password
password
password
pa(sword
passwd
password
password

View File

@ -0,0 +1,24 @@
#login
machine x.y login y password x
máchine a.b
locdef m
c1 a
c2 b
micdef mm
c1 a
c2 z
#
m
achine x.y login y password x
machine a.b
logyn b
password a
macdef m
c1 a
c2 b
logynmacdef mm
c1 a
c2 z

View File

@ -0,0 +1,21 @@
#mx
##
#
"
"
##
"
#
#
#
#
#
#
#
Η#
#
<EFBFBD>
#
#
Ϋ

View File

@ -0,0 +1,256 @@


View File

@ -0,0 +1,34 @@
machine
macdef
)
)
)
f
)
)
)
)
)
m
)
m

2
)
)
)
m
)
m

2
)
)
)
)
)
)
)
a
)
a

View File

@ -0,0 +1,4 @@
#
machine x.ymacdef login y password x
maűssword x
maűűűűűűűűűűűűűűűűűűűűűűűűű'űűűűűűűűűűűűűűűűchine x.y w

View File

@ -0,0 +1,4 @@
#
maűűŞ űűűűűűűűűa
äßśÍ z'

View File

@ -0,0 +1,14 @@
#
machine x.ogin b
password a
macdef m
c1 a
c2 b
macdef mm
cword a
macdef m
c1 a
c21 a
c2 z

View File

@ -0,0 +1,8 @@
dault port
port
port
port
port
porj
port
port

View File

@ -0,0 +1,3 @@
default
force ye force ye
force Ye force Ye

View File

@ -0,0 +1,48 @@
machine
login
macn
default
login
ºlogin
machine
default
login
º
machine
lo
login
machine
login
machine
login
defagin
default
login
ºlogin
machine
login
machine
login
default
login
º
machine
loGin
machine
logdefaultine
login
default
lo'gin
machine
login
machine
login
machine
login
defaultGin
machine
logdefauac!hine
login
default
login

View File

@ -0,0 +1,3 @@
#
machine x.y login ûûûûûûßûûûûûûûûûûe x.y login y password x1 c2 z

View File

@ -0,0 +1,4 @@
";orceorõpaR wor\rä
!
a

View File

@ -0,0 +1 @@
mde force ye

View File

@ -0,0 +1,13 @@
#logyn
machine x.y login y padefaultx
machine a.b
login b
pass÷ord x
machine a.b
loginy login y padefaultx
machine a.b
login b
pass÷ord x
machine a.g
login c2 z

View File

@ -0,0 +1,4 @@
de¾ault force G
force G
fo G
force G

View File

@ -0,0 +1,35 @@
y
m!chine
passwor
password
password
password
password
password
pa(sword
password
password
password
password
password
password
password
password
password
paspasswnrd
password
password
password
password
password
pa(sword
password
password
password
password
password
password
password
password
password
ðassword

View File

@ -0,0 +1,15 @@
machine x|i
machine ű#
machine x.y
machine X.y
machine 8.y machine x.)cy
machine x.yd machine śž
machine m machine yx.
machine !e
machine *e xo
machine ult
machine mat machine yxt
cnebt
machine }
machine x.o default machine xe
machine xf—

View File

@ -0,0 +1,14 @@
machine l#
machine _ machine zy machine ;
machine a.b machine aV
machine a
machine _6 machine x) machine xy machine 
machine _0
machine 
machine 1 machine x machine €
machine d
machine n
machine 0 machine y machine
machine pg
machine Y
machine 

View File

@ -0,0 +1,10 @@
machine machine y machine o default machine l
machine
machine m machine t
machine !
machine b machine f
machine ÿ
machine s
machine e
machine g
machine x

View File

@ -0,0 +1,77 @@
dmaûssw
!
login
lo
login
login
lmaûssw
!
login
lo
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
ogin
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login

View File

@ -0,0 +1,7 @@
machine
machine c machine Ő default
machine .
machine x machine u
machine t machine l
machine #
machine y machine ě

View File

@ -0,0 +1,40 @@
d!efault
!
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
login
logi)n

View File

@ -0,0 +1 @@
ûct=wget_ne û û x  û û y x ) " ' . û û x ú û \\\\\\\\\\\\\\\\ | x  û û y . ú û } x 7 û û x  û û y . ú login 5 û û y a x û û ) * 'û û x ú û | * . . û û x û û )

View File

@ -0,0 +1,2 @@
#
""&""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""#

View File

@ -0,0 +1 @@
mohne ".m

View File

@ -0,0 +1,13 @@
#
macdefmachine x.yŠ login y password x
maűűűűűűűűűűűűűűűűűűűűűűűűűűűűűűűűűűűűűűűűűűűchine a.b
logyn b
password a
macdef m
c1 a
c2 b
macdef mm
c1 a
c2z

View File

@ -0,0 +1,9 @@
def¨Š“õ“<EFBFBD>˜in
login
logi
olingnlogin
login
<EFBFBD>˜õ“˜gin
login

View File

@ -0,0 +1,133 @@
в
m
c
c
c
Т
m
c
c
c
c
Т
m
c
c
c c
c
Т
r
вm
m
c
c
c
Т
m
c
Т
m
c
c
c
Т
Т
r
m
в
m
c
m
c
c
c
Т
m
c
c
c
c
c
Т
c c
c
Т
r
m
в
m
c
c
c c
c
Т
r
вm
m
c
c
c
Т
m
c
Т
m
c
c
c
Т
Т
r
m
в
m
c
m
c
c
c
Т
m
c
c
c
c
c
Т
m
c
c
c c
c
Т
r
m
c
c
c
Т
m
c
c
c
c
c
Т
m
c
c
c c
c
Т
в
m
c
c
c
Т
m
c
c

View File

@ -0,0 +1,3 @@
defaultcr foe G
force G
force G

View File

@ -0,0 +1,13 @@
#
machine x.y login y password x
macmachineb
login b
password a
macdef m
c1 a
c2 b
macdef mm
c1 a
c2 z

View File

@ -0,0 +1,4 @@
#
maûûªûûûûûûûûûa
äßœ

View File

@ -0,0 +1,17 @@
machine
port
port
port
port
port
port
port
port
port
port
port
port
port
port
port
port

View File

@ -0,0 +1,2 @@
#
machine ûûûûûûchinmacdefe v.y login y paspasswosw

View File

@ -0,0 +1,14 @@
y
machine x mae
f
#
c
#
#
login
#
#:
deord
password
de

View File

@ -0,0 +1 @@
default force T

View File

@ -0,0 +1,17 @@
madefaultchine
port
port
port
port
port
port
port
port
port
port
port
povt
port
port
port
port

View File

@ -0,0 +1,6 @@
#
default x.y login y password x
#
machine x.y#
default x.y login y hine a.bmaûûûûû
logyn bûûûûû

View File

@ -0,0 +1,11 @@
machine t machine y machine o default machine c
machine m machine e#
machine l
machine
machine .
machine ie machine f
machine p
machine xe
machine g
machine x

View File

@ -0,0 +1,6 @@
default
default default default default
default default default default default default default default
default default default default default default
default default default default default default default default
default default default default default

View File

@ -0,0 +1,3 @@
m
port
pt

View File

@ -0,0 +1,467 @@
#˙˙˙˙˙˙˙
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
+
#
2
#
#
#
#
#
#
#
#
"
;#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
+
#
##
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
"
;#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
+
##
#
#
#
#
#
##
#
#
#
"
#
#
#
#
#
#
#
"
#
#
#
#'#
#
#
#
#
#
#
#machine#
#
#
#˙˙˙˙˙default˙˙˙˙
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
##
##
#
#
#
#
#
#
#
#
#
"
#
#
#
#
#
#
#
"
#
#
#
#'#
#
#
#
#
#
#
#
#
#
##
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
˙˙˙˙˙˙˙#
#
"
#
#
#
#˙˙
#
#
#
"
#
#
login#
#
#
password#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
"
;#
#
#
#
#
#
#
"
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
##
#
#
#
"
#
#
#
#
#
#
#
"
#
#
#
#'#
#
#
#
#
#
#
#machine#
#
#
#˙˙˙˙˙default˙˙˙˙
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
##
##
#
#
#
#
#
#
#
#
#
"
#
#
#
#
#
#
#
"
#
#
#
#'#
#
#
#
#
#
#
#
#
#
##
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
˙˙˙˙˙˙˙#
#
"
#
#
#
#˙˙
#
#
#
"
#
#
login#
#
#
#
#
#
#
#
#
#
#

View File

@ -0,0 +1,4 @@
#
machine x.ymacdef ¥¥¥¥§¥¥¥¥login y password õôôôôôôø
x
maûssword w

View File

@ -0,0 +1,319 @@
ðachine
accou
force
force
force
force
force
force
fforce
force
forc*:
force
force
force"""""""""#
machine x.y *logi"""""""""""""""""n """""""""b"""""""""""""""""""""""""""""""""""""""
force
fo;rce
force
force
force
force
force
force
force
force
frce
orce
force
force
force
force
force
forceforce
force
force
force
force
force
force
forou
force
force
force
force
force
force
fforce
force
force
force
force
force
force
force
forcforce
force
force
force
force
forou
force
force
force
force
force
force
fforce
force
force
force
force
force
force
force
force
force
force
force
force
force
force
force
force
force
orce
force
force
force
šœšõforce
force
forc*:
force
force
force"""""""""#
machine x.y *logi"""""""""""""""""""""""""""""macdef""""""""""""""""""n """""""""b""""""""""""""
force
fo;rce
force
force
force
force
force
force
force
force
frce
orce
force
force
force
force
force
forceforce
force
force
force
force
force
force
forou
force
force
force
force
force
force
fforce
force
force
force
force
force
force
force
force
force
force
fo"""""""""""""""""""""""""""""""""""
force
force
force
force
force
force
force
force
force
force
frce
orce
force
force
force
force
force
forceforce
force
force
force
force
force
force
forou
force
force
force
force
force
force
fforce
force
force
force
force
force
force
force
force
force
force
force
force
force
force
force
force
force
orce
force
force
force
šœšõforce
force
force
force
forcc
fo
forc;e
force
—rce
force
force
force
force
force
force
force
force
force
force
force
orce
force
force
force
fce
force
force
foy passwordrc x
#ûûûûû
logyn bûûûûe
forc;e
forceoû
rcee
force
šœšõforce
force
force
force
forcc
fo
forc;e
force
—rce
force
force
force
force
force
force
force
force
force
force
force
orce
force
force
force
fce
force
force
foy passwordrc x
#ûûce
force
force
forcc
fo
forc;e
force
—rce
force
force
force
force
force
force
force
force
force
force
force
orce
force
force
force
fce
force
force
foy passwordrc x
#ûûûûû
logyn bûûûûe
forc;e
forceoû
rcee
force
šœšõforce
force
force
force
forcc
fo
forc;e
force
—rce
force
force
force
force
force
force
force
force
force
force
force
orce
force
force
force
fce
force
force
foy passwordrc x
#ûûûûû
logyn bûûûûe
forc;e
forceoû
rceforce

View File

@ -0,0 +1,17 @@
ymachinee
password
password
password
password
password
pa.sword
password
password
password
password
password
password
password
password
password
tassw<EFBFBD>_bbb<EFBFBD>ord

View File

@ -0,0 +1,11 @@
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\swo
pas\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\(\\\\sword
machine
machine
passwo
pas\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\®\\\\\\sword
machine
pas$swÚrd
rachine
password

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