File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
include/tao/json/events/ubjson Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ namespace tao
162162 }
163163
164164 template < typename Input >
165- static std::size_t read_size ( Input& in )
165+ static std::uint64_t read_unsigned ( Input& in )
166166 {
167167 in.bump_in_this_line (); // Skip marker byte.
168168 if ( !in.size ( 1 ) ) {
@@ -187,6 +187,16 @@ namespace tao
187187 throw json_pegtl::parse_error ( " unexpected ubjson high precision number size marker" , in );
188188 }
189189
190+ template < typename Input >
191+ static std::size_t read_size ( Input& in )
192+ {
193+ const auto s = read_unsigned ( in );
194+ if ( s > static_cast < std::uint64_t >( std::numeric_limits< std::size_t >::max () ) ) {
195+ throw json_pegtl::parse_error ( " size too large for 32-bit platform" , in );
196+ }
197+ return static_cast < std::size_t >( s );
198+ }
199+
190200 template < typename Input, typename Consumer >
191201 static bool match_high_precision ( Input& in, Consumer& consumer )
192202 {
You can’t perform that action at this time.
0 commit comments