Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
ec098ffc
Commit
ec098ffc
authored
Feb 14, 2016
by
Niels
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #207 from msm-/afl-fuzz
add support for afl-fuzz testing
parents
61fe90f9
9e500b49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
2 deletions
+54
-2
Makefile
Makefile
+12
-2
test/fuzz.cpp
test/fuzz.cpp
+42
-0
No files found.
Makefile
View file @
ec098ffc
...
...
@@ -9,7 +9,7 @@ all: json_unit
# clean up
clean
:
rm
-f
json_unit json_benchmarks
rm
-f
json_unit json_benchmarks
fuzz
##########################################################################
...
...
@@ -24,6 +24,16 @@ json_unit: test/unit.cpp src/json.hpp test/catch.hpp
$(CXX)
-std
=
c++11
$(CXXFLAGS)
$(FLAGS)
$(CPPFLAGS)
-I
src
-I
test
$<
$(LDFLAGS)
-o
$@
##########################################################################
# fuzzing
##########################################################################
fuzz
:
test/fuzz.cpp src/json.hpp
$(CXX)
-std
=
c++11
$(CXXFLAGS)
$(FLAGS)
$(CPPFLAGS)
-I
src
-I
test
$<
$(LDFLAGS)
-lstdc
++
-lm
-o
$@
fuzz_testcases
:
mkdir
-p
testcases
&&
find
test
/
-size
-5k
-name
*
json | xargs
-I
{}
cp
"{}"
testcases
@
echo
"Test cases suitable for fuzzing have been copied into the testcases directory"
##########################################################################
# static analyzer
##########################################################################
...
...
@@ -48,7 +58,7 @@ pretty:
--indent-col1-comments
--pad-oper
--pad-header
--align-pointer
=
type
\
--align-reference
=
type
--add-brackets
--convert-tabs
--close-templates
\
--lineend
=
linux
--preserve-date
--suffix
=
none
\
src/json.hpp src/json.hpp.re2c
test
/unit.cpp benchmarks/benchmarks.cpp doc/examples/
*
.cpp
src/json.hpp src/json.hpp.re2c
test
/unit.cpp
test
/fuzz.cpp
benchmarks/benchmarks.cpp doc/examples/
*
.cpp
##########################################################################
...
...
test/fuzz.cpp
0 → 100644
View file @
ec098ffc
/*
__ _____ _____ _____
__| | __| | | | JSON for Modern C++ (fuzz test support)
| | |__ | | | | | | version 2.0.0
|_____|_____|_____|_|___| https://github.com/nlohmann/json
To run under afl:
afl-fuzz -i testcases -o output ./fuzz
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
*/
#include <json.hpp>
using
json
=
nlohmann
::
json
;
int
main
()
{
json
*
jp
;
#ifdef __AFL_HAVE_MANUAL_CONTROL
while
(
__AFL_LOOP
(
1000
))
{
#endif
jp
=
new
json
();
json
j
=
*
jp
;
try
{
j
<<
std
::
cin
;
}
catch
(
std
::
invalid_argument
e
)
{
std
::
cout
<<
"Invalid argument in parsing"
<<
e
.
what
()
<<
'\n'
;
}
if
(
j
.
find
(
"foo"
)
!=
j
.
end
())
{
std
::
cout
<<
"Found a foo"
;
}
std
::
cout
<<
j
.
type
()
<<
j
<<
std
::
endl
;
delete
jp
;
#ifdef __AFL_HAVE_MANUAL_CONTROL
}
#endif
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment