Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
c05bd904
Unverified
Commit
c05bd904
authored
Jun 12, 2020
by
Niels Lohmann
Committed by
GitHub
Jun 12, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2182 from tanuj208/develop
Improve parse_ubjson_fuzzer
parents
27f5a6e8
c3c5c03e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
3 deletions
+19
-3
fuzzer-parse_ubjson.cpp
test/src/fuzzer-parse_ubjson.cpp
+19
-3
No files found.
test/src/fuzzer-parse_ubjson.cpp
View file @
c05bd904
...
@@ -11,6 +11,12 @@ array data, it performs the following steps:
...
@@ -11,6 +11,12 @@ array data, it performs the following steps:
- vec = to_ubjson(j1)
- vec = to_ubjson(j1)
- j2 = from_ubjson(vec)
- j2 = from_ubjson(vec)
- assert(j1 == j2)
- assert(j1 == j2)
- vec2 = to_ubjson(j1, use_size = true, use_type = false)
- j3 = from_ubjson(vec2)
- assert(j1 == j3)
- vec3 = to_ubjson(j1, use_size = true, use_type = true)
- j4 = from_ubjson(vec3)
- assert(j1 == j4)
The provided function `LLVMFuzzerTestOneInput` can be used in different fuzzer
The provided function `LLVMFuzzerTestOneInput` can be used in different fuzzer
drivers.
drivers.
...
@@ -35,14 +41,24 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
...
@@ -35,14 +41,24 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
try
try
{
{
// step 2: round trip
// step 2.1: round trip without adding size annotations to container types
std
::
vector
<
uint8_t
>
vec2
=
json
::
to_ubjson
(
j1
);
std
::
vector
<
uint8_t
>
vec2
=
json
::
to_ubjson
(
j1
,
false
,
false
);
// step 2.2: round trip with adding size annotations but without adding type annonations to container types
std
::
vector
<
uint8_t
>
vec3
=
json
::
to_ubjson
(
j1
,
true
,
false
);
// step 2.3: round trip with adding size as well as type annotations to container types
std
::
vector
<
uint8_t
>
vec4
=
json
::
to_ubjson
(
j1
,
true
,
true
);
// parse serialization
// parse serialization
json
j2
=
json
::
from_ubjson
(
vec2
);
json
j2
=
json
::
from_ubjson
(
vec2
);
json
j3
=
json
::
from_ubjson
(
vec3
);
json
j4
=
json
::
from_ubjson
(
vec4
);
// serializations must match
// serializations must match
assert
(
json
::
to_ubjson
(
j2
)
==
vec2
);
assert
(
json
::
to_ubjson
(
j2
,
false
,
false
)
==
vec2
);
assert
(
json
::
to_ubjson
(
j3
,
true
,
false
)
==
vec3
);
assert
(
json
::
to_ubjson
(
j4
,
true
,
true
)
==
vec4
);
}
}
catch
(
const
json
::
parse_error
&
)
catch
(
const
json
::
parse_error
&
)
{
{
...
...
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