Skip to content

Commit 70dc851

Browse files
committed
fix: tighter checks for serialization
1 parent a0b2ec0 commit 70dc851

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

include/msgpack/v1/adaptor/cpp11/tuple.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#ifndef MSGPACK_V1_TYPE_CPP11_TUPLE_HPP
1111
#define MSGPACK_V1_TYPE_CPP11_TUPLE_HPP
1212

13+
#include "msgpack/v3/unpack_decl.hpp"
1314
#include "msgpack/versioning.hpp"
1415
#include "msgpack/adaptor/adaptor_base.hpp"
1516
#include "msgpack/object.hpp"
@@ -114,6 +115,11 @@ struct as<std::tuple<Args...>, typename std::enable_if<msgpack::any_of<msgpack::
114115
std::tuple<Args...> operator()(
115116
msgpack::object const& o) const {
116117
if (o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
118+
// <barretenberg>
119+
if ((o.via.array.size != sizeof...(Args)) {
120+
throw msgpack::unpack_error(std::string("tuple array not right size, got ") + std::to_string(o.via.array.size) + " but expected " + std::to_string(sizeof...(Args)));
121+
}
122+
// </barretenberg>
117123
return StdTupleAs<Args...>::as(o);
118124
}
119125
};

include/msgpack/v1/adaptor/detail/cpp11_define_map.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "msgpack/v1/adaptor/detail/cpp11_define_map_decl.hpp"
1414
#include "msgpack/v1/adaptor/detail/cpp11_convert_helper.hpp"
15+
#include "msgpack/v3/object_fwd_decl.hpp"
1516

1617
#include <tuple>
1718
#include <map>
@@ -36,6 +37,10 @@ struct define_map_imp {
3637
auto it = kvmap.find(std::get<N-2>(t));
3738
if (it != kvmap.end()) {
3839
convert_helper(*it->second, std::get<N-1>(t));
40+
} else {
41+
// <barretenberg>
42+
throw msgpack::unpack_error(std::string("Missing field " + std::get<N-2>(t)));
43+
// </barretenberg>
3944
}
4045
}
4146
static void object(msgpack::object* o, msgpack::zone& z, Tuple const& t) {

0 commit comments

Comments
 (0)