Skip to content

Commit 6434e7a

Browse files
author
Yuki Ito
committed
Validate map size
1 parent e536ec5 commit 6434e7a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/msgpack_packer.erl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,11 @@ pack_map(M, Opt)->
312312
Len when Len < 16#10000 -> % 65536
313313
<<16#DE:8, Len:16/big-unsigned-integer-unit:1,
314314
(<< <<(pack(K, Opt))/binary, (pack(V, Opt))/binary>> || {K, V} <- M >>)/binary>>;
315-
Len ->
315+
Len when Len < 16#100000000->
316316
<<16#DF:8, Len:32/big-unsigned-integer-unit:1,
317-
(<< <<(pack(K, Opt))/binary, (pack(V, Opt))/binary>> || {K, V} <- M >>)/binary>>
317+
(<< <<(pack(K, Opt))/binary, (pack(V, Opt))/binary>> || {K, V} <- M >>)/binary>>;
318+
_ ->
319+
{error, {badarg, M}}
318320
end.
319321

320322
-spec pack_ext(any(), msgpack_ext_packer(), msgpack:options()) -> {ok, binary()} | {error, any()}.

0 commit comments

Comments
 (0)