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
b15fc13d
Unverified
Commit
b15fc13d
authored
Apr 04, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔨
implemented MessagePack in binary_reader
parent
3a34f2d8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
26 deletions
+19
-26
json.hpp
src/json.hpp
+0
-0
unit-cbor.cpp
test/src/unit-cbor.cpp
+0
-7
unit-msgpack.cpp
test/src/unit-msgpack.cpp
+15
-15
unit-regression.cpp
test/src/unit-regression.cpp
+4
-4
No files found.
src/json.hpp
View file @
b15fc13d
This diff is collapsed.
Click to expand it.
test/src/unit-cbor.cpp
View file @
b15fc13d
...
@@ -28,7 +28,6 @@ SOFTWARE.
...
@@ -28,7 +28,6 @@ SOFTWARE.
#include "catch.hpp"
#include "catch.hpp"
#define private public
#include "json.hpp"
#include "json.hpp"
using
nlohmann
::
json
;
using
nlohmann
::
json
;
...
@@ -1357,12 +1356,6 @@ TEST_CASE("CBOR regressions", "[!throws]")
...
@@ -1357,12 +1356,6 @@ TEST_CASE("CBOR regressions", "[!throws]")
}
}
}
}
}
}
SECTION
(
"improve code coverage"
)
{
// exotic edge case
CHECK_THROWS_AS
(
json
::
check_length
(
0xffffffffffffffffull
,
0xfffffffffffffff0ull
,
0xff
),
json
::
parse_error
);
}
}
}
TEST_CASE
(
"CBOR roundtrips"
,
"[hide]"
)
TEST_CASE
(
"CBOR roundtrips"
,
"[hide]"
)
...
...
test/src/unit-msgpack.cpp
View file @
b15fc13d
...
@@ -1038,35 +1038,35 @@ TEST_CASE("MessagePack")
...
@@ -1038,35 +1038,35 @@ TEST_CASE("MessagePack")
CHECK_THROWS_AS
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
})),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
})),
json
::
parse_error
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcc
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcc
})),
"[json.exception.parse_error.110] parse error at 2:
cannot read 1 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at 2:
unexpected end of input
"
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcd
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcd
})),
"[json.exception.parse_error.110] parse error at 2:
cannot read 2 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at 2:
unexpected end of input
"
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcd
,
0x00
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcd
,
0x00
})),
"[json.exception.parse_error.110] parse error at
2: cannot read 2 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at
3: unexpected end of input
"
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xce
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xce
})),
"[json.exception.parse_error.110] parse error at 2:
cannot read 4 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at 2:
unexpected end of input
"
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xce
,
0x00
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xce
,
0x00
})),
"[json.exception.parse_error.110] parse error at
2: cannot read 4 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at
3: unexpected end of input
"
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xce
,
0x00
,
0x00
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xce
,
0x00
,
0x00
})),
"[json.exception.parse_error.110] parse error at
2: cannot read 4 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at
4: unexpected end of input
"
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xce
,
0x00
,
0x00
,
0x00
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xce
,
0x00
,
0x00
,
0x00
})),
"[json.exception.parse_error.110] parse error at
2: cannot read 4 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at
5: unexpected end of input
"
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
})),
"[json.exception.parse_error.110] parse error at 2:
cannot read 8 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at 2:
unexpected end of input
"
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
})),
"[json.exception.parse_error.110] parse error at
2: cannot read 8 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at
3: unexpected end of input
"
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
,
0x00
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
,
0x00
})),
"[json.exception.parse_error.110] parse error at
2: cannot read 8 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at
4: unexpected end of input
"
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
,
0x00
,
0x00
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
,
0x00
,
0x00
})),
"[json.exception.parse_error.110] parse error at
2: cannot read 8 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at
5: unexpected end of input
"
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
,
0x00
,
0x00
,
0x00
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
,
0x00
,
0x00
,
0x00
})),
"[json.exception.parse_error.110] parse error at
2: cannot read 8 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at
6: unexpected end of input
"
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
})),
"[json.exception.parse_error.110] parse error at
2: cannot read 8 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at
7: unexpected end of input
"
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
})),
"[json.exception.parse_error.110] parse error at
2: cannot read 8 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at
8: unexpected end of input
"
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
})),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
std
::
vector
<
uint8_t
>
({
0xcf
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
})),
"[json.exception.parse_error.110] parse error at
2: cannot read 8 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at
9: unexpected end of input
"
);
}
}
SECTION
(
"unsupported bytes"
)
SECTION
(
"unsupported bytes"
)
...
...
test/src/unit-regression.cpp
View file @
b15fc13d
...
@@ -638,13 +638,13 @@ TEST_CASE("regression tests")
...
@@ -638,13 +638,13 @@ TEST_CASE("regression tests")
std
::
vector
<
uint8_t
>
vec1
{
0xcb
,
0x8f
,
0x0a
};
std
::
vector
<
uint8_t
>
vec1
{
0xcb
,
0x8f
,
0x0a
};
CHECK_THROWS_AS
(
json
::
from_msgpack
(
vec1
),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
from_msgpack
(
vec1
),
json
::
parse_error
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
vec1
),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
vec1
),
"[json.exception.parse_error.110] parse error at
2: cannot read 8 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at
4: unexpected end of input
"
);
// related test case: incomplete float32
// related test case: incomplete float32
std
::
vector
<
uint8_t
>
vec2
{
0xca
,
0x8f
,
0x0a
};
std
::
vector
<
uint8_t
>
vec2
{
0xca
,
0x8f
,
0x0a
};
CHECK_THROWS_AS
(
json
::
from_msgpack
(
vec2
),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
from_msgpack
(
vec2
),
json
::
parse_error
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
vec2
),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
vec2
),
"[json.exception.parse_error.110] parse error at
2: cannot read 4 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at
4: unexpected end of input
"
);
// related test case: incomplete Half-Precision Float (CBOR)
// related test case: incomplete Half-Precision Float (CBOR)
std
::
vector
<
uint8_t
>
vec3
{
0xf9
,
0x8f
};
std
::
vector
<
uint8_t
>
vec3
{
0xf9
,
0x8f
};
...
@@ -671,7 +671,7 @@ TEST_CASE("regression tests")
...
@@ -671,7 +671,7 @@ TEST_CASE("regression tests")
std
::
vector
<
uint8_t
>
vec1
{
0x87
};
std
::
vector
<
uint8_t
>
vec1
{
0x87
};
CHECK_THROWS_AS
(
json
::
from_msgpack
(
vec1
),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
from_msgpack
(
vec1
),
json
::
parse_error
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
vec1
),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
vec1
),
"[json.exception.parse_error.110] parse error at 2:
cannot read 1 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at 2:
unexpected end of input
"
);
// more test cases for MessagePack
// more test cases for MessagePack
for
(
auto
b
:
for
(
auto
b
:
...
@@ -708,7 +708,7 @@ TEST_CASE("regression tests")
...
@@ -708,7 +708,7 @@ TEST_CASE("regression tests")
"[json.exception.parse_error.110] parse error at 1: unexpected end of input"
);
"[json.exception.parse_error.110] parse error at 1: unexpected end of input"
);
CHECK_THROWS_AS
(
json
::
from_msgpack
(
vec2
),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
from_msgpack
(
vec2
),
json
::
parse_error
);
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
vec2
),
CHECK_THROWS_WITH
(
json
::
from_msgpack
(
vec2
),
"[json.exception.parse_error.110] parse error at 1:
cannot read 1 bytes from vector
"
);
"[json.exception.parse_error.110] parse error at 1:
unexpected end of input
"
);
}
}
SECTION
(
"issue #411 - Heap-buffer-overflow (OSS-Fuzz issue 366)"
)
SECTION
(
"issue #411 - Heap-buffer-overflow (OSS-Fuzz issue 366)"
)
...
...
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