Commit e1b89dd1 by Niels Lohmann

Merge branch 'develop' into feature/release_information

parents ea4d71ee 9f6c86f2
...@@ -600,6 +600,7 @@ Thanks a lot for helping out! ...@@ -600,6 +600,7 @@ Thanks a lot for helping out!
- Other encodings such as Latin-1, UTF-16, or UTF-32 are not supported and will yield parse errors. - Other encodings such as Latin-1, UTF-16, or UTF-32 are not supported and will yield parse errors.
- [Unicode noncharacters](http://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library. - [Unicode noncharacters](http://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library.
- Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors. - Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors.
- The strings stored in the library are UTF-8 encoded. When using the default string type (`std::string`), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs.
## Execute unit tests ## Execute unit tests
......
...@@ -52,7 +52,7 @@ TESTCASES = $(patsubst src/unit-%.cpp,test-%,$(wildcard src/unit-*.cpp)) ...@@ -52,7 +52,7 @@ TESTCASES = $(patsubst src/unit-%.cpp,test-%,$(wildcard src/unit-*.cpp))
all: $(TESTCASES) all: $(TESTCASES)
clean: clean:
rm -fr json_unit $(OBJECTS) $(SOURCES:.cpp=.gcno) $(SOURCES:.cpp=.gcda) $(TESTCASES) rm -fr json_unit $(OBJECTS) $(SOURCES:.cpp=.gcno) $(SOURCES:.cpp=.gcda) $(TESTCASES) parse_afl_fuzzer parse_cbor_fuzzer parse_msgpack_fuzzer
############################################################################## ##############################################################################
# single test file # single test file
...@@ -85,13 +85,14 @@ check: $(TESTCASES) ...@@ -85,13 +85,14 @@ check: $(TESTCASES)
# fuzzer # fuzzer
############################################################################## ##############################################################################
FUZZER_ENGINE = src/fuzzer-driver_afl.cpp
fuzzers: parse_afl_fuzzer parse_cbor_fuzzer parse_msgpack_fuzzer fuzzers: parse_afl_fuzzer parse_cbor_fuzzer parse_msgpack_fuzzer
parse_afl_fuzzer: parse_afl_fuzzer:
$(CXX) $(CXXFLAGS) $(CPPFLAGS) src/fuzzer-driver_afl.cpp src/fuzzer-parse_json.cpp -o $@ $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(FUZZER_ENGINE) src/fuzzer-parse_json.cpp -o $@
parse_cbor_fuzzer: parse_cbor_fuzzer:
$(CXX) $(CXXFLAGS) $(CPPFLAGS) src/fuzzer-driver_afl.cpp src/fuzzer-parse_cbor.cpp -o $@ $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(FUZZER_ENGINE) src/fuzzer-parse_cbor.cpp -o $@
parse_msgpack_fuzzer: parse_msgpack_fuzzer:
$(CXX) $(CXXFLAGS) $(CPPFLAGS) src/fuzzer-driver_afl.cpp src/fuzzer-parse_msgpack.cpp -o $@ $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(FUZZER_ENGINE) src/fuzzer-parse_msgpack.cpp -o $@
...@@ -80,7 +80,7 @@ struct my_allocator : std::allocator<T> ...@@ -80,7 +80,7 @@ struct my_allocator : std::allocator<T>
} }
else else
{ {
::new(reinterpret_cast<void*>(p)) T(std::forward<Args>(args)...); ::new (reinterpret_cast<void*>(p)) T(std::forward<Args>(args)...);
} }
} }
......
...@@ -912,7 +912,7 @@ TEST_CASE("constructors") ...@@ -912,7 +912,7 @@ TEST_CASE("constructors")
SECTION("array") SECTION("array")
{ {
json j { {"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false} , 13 }; json j { {"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false}, 13 };
CHECK(j.type() == json::value_t::array); CHECK(j.type() == json::value_t::array);
} }
} }
......
...@@ -663,4 +663,31 @@ TEST_CASE("regression tests") ...@@ -663,4 +663,31 @@ TEST_CASE("regression tests")
std::vector<uint8_t> vec3 {0xbf, 0x61, 0x61, 0x01}; std::vector<uint8_t> vec3 {0xbf, 0x61, 0x61, 0x01};
CHECK_THROWS_AS(json::from_cbor(vec3), std::out_of_range); CHECK_THROWS_AS(json::from_cbor(vec3), std::out_of_range);
} }
SECTION("issue #416 - Use-of-uninitialized-value (OSS-Fuzz issue 377)")
{
// original test case
std::vector<uint8_t> vec1
{
0x94, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa,
0x3a, 0x96, 0x96, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4,
0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0x71,
0xb4, 0xb4, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0x3a,
0x96, 0x96, 0xb4, 0xb4, 0xfa, 0x94, 0x94, 0x61,
0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0xfa
};
CHECK_THROWS_AS(json::from_cbor(vec1), std::out_of_range);
// related test case: double-precision
std::vector<uint8_t> vec2
{
0x94, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa,
0x3a, 0x96, 0x96, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4,
0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0x71,
0xb4, 0xb4, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0x3a,
0x96, 0x96, 0xb4, 0xb4, 0xfa, 0x94, 0x94, 0x61,
0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0xfb
};
CHECK_THROWS_AS(json::from_cbor(vec2), std::out_of_range);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment