1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-22 15:21:52 +03:00

💥 CBOR/MessagePack input must end with EOF #505

The CBOR and MessagePack parsers now expect the input to be read until the end. Unless the new parameter "strict" is set to false (it is true by default), an exception is raised if the parser ends prematurely. This is a breaking change as the parsers ignored unread input so far.

Furthermore, the offset/startIndex paramter introduced in #462 was removed as this behavior can be mimicked with an iterator range. For instance, instead of calling "from_cbor(vec, 5);", you can write "from_cbor({vec.begin()+5, vec.end()});".
This commit is contained in:
Niels Lohmann
2017-08-16 14:48:23 +02:00
parent 1f31a5b808
commit 22b59693f1
4 changed files with 86 additions and 51 deletions

View File

@ -1108,7 +1108,7 @@ TEST_CASE("regression tests")
SECTION("issue #504 - assertion error (OSS-Fuzz 856)")
{
std::vector<uint8_t> vec1 = {0xf9, 0xff, 0xff, 0x4a, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x37, 0x02, 0x38};
json j1 = json::from_cbor(vec1);
json j1 = json::from_cbor(vec1, false);
// step 2: round trip
std::vector<uint8_t> vec2 = json::to_cbor(j1);