diff --git a/source/include/parselink/msgpack/token/reader.h b/source/include/parselink/msgpack/token/reader.h index 960cfd4..4a28bec 100644 --- a/source/include/parselink/msgpack/token/reader.h +++ b/source/include/parselink/msgpack/token/reader.h @@ -80,6 +80,7 @@ public: long int size = 0; std::size_t var_size = 0; auto id = *curr; + traits& format::type token_type; ++curr; switch (id) { @@ -127,27 +128,34 @@ public: size = sizeof(format::str32::first_type); token_type = format::type::string; break; + case format::bin8::marker: + size = sizeof(format::bin8::first_type); + token_type = format::type::bytes; + break; + case format::bin16::marker: + size = sizeof(format::bin16::first_type); + token_type = format::type::bytes; + break; + case format::bin32::marker: + size = sizeof(format::bin32::first_type); + token_type = format::type::bytes; + break; default: return tl::make_unexpected(error::not_implemented); } + if (remaining(curr) < size) { + return tl::make_unexpected(error::incomplete_message); + } + switch (token_type) { case format::type::unsigned_int: - if (remaining(curr) < size) { - return tl::make_unexpected(error::out_of_space); - } tok = detail::read_value(size, curr); break; case format::type::signed_int: - if (remaining(curr) < size) { - return tl::make_unexpected(error::out_of_space); - } tok = detail::read_value(size, curr); break; case format::type::string: - if (remaining(curr) < size) { - return tl::make_unexpected(error::incomplete_message); - } var_size = std::bit_cast(detail::read(size, curr)); if (std::size_t(remaining(curr)) < var_size) { return tl::make_unexpected(error::incomplete_message);