diff options
author | Sverker Eriksson <[email protected]> | 2013-11-18 16:56:40 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2013-11-18 17:03:55 +0100 |
commit | ee0ca14382e76d97285e64b3396fbb87f33e23da (patch) | |
tree | e1c8ce7912b0808d5669f69cdb031111e439f14f /erts/emulator/test | |
parent | 20641fe0f2ea745873fc7557448d3a7deb1bd639 (diff) | |
download | otp-ee0ca14382e76d97285e64b3396fbb87f33e23da.tar.gz otp-ee0ca14382e76d97285e64b3396fbb87f33e23da.tar.bz2 otp-ee0ca14382e76d97285e64b3396fbb87f33e23da.zip |
erts: Fix bugs in binary_to_term for invalid bitstrings
<<131, 77, Len:32, Bits:8, Data/binary>>
badarg if Bits > 8
Used to return internally inconsistent bitstring
badarg if Len==0 and Bits > 0
Used to return invalid *huge* binary (size = (Uint)-1)
badarg if Bits==0 and Len > 0
Used to return valid binary as if Bits was 8
Diffstat (limited to 'erts/emulator/test')
-rw-r--r-- | erts/emulator/test/binary_SUITE.erl | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/erts/emulator/test/binary_SUITE.erl b/erts/emulator/test/binary_SUITE.erl index 08ab094019..d2c4a8ff3c 100644 --- a/erts/emulator/test/binary_SUITE.erl +++ b/erts/emulator/test/binary_SUITE.erl @@ -631,7 +631,12 @@ safe_binary_to_term2(Config) when is_list(Config) -> bad_terms(suite) -> []; bad_terms(Config) when is_list(Config) -> - ?line test_terms(fun corrupter/1). + ?line test_terms(fun corrupter/1), + {'EXIT',{badarg,_}} = (catch binary_to_term(<<131,$M,3:32,0,11,22,33>>)), + {'EXIT',{badarg,_}} = (catch binary_to_term(<<131,$M,3:32,9,11,22,33>>)), + {'EXIT',{badarg,_}} = (catch binary_to_term(<<131,$M,0:32,1,11,22,33>>)), + ok. + corrupter(Term) when is_function(Term); is_function(hd(Term)); @@ -1221,14 +1226,9 @@ gc() -> gc1() -> ok. bit_sized_binary_sizes(Config) when is_list(Config) -> - ?line [bsbs_1(A) || A <- lists:seq(0, 7)], + ?line [bsbs_1(A) || A <- lists:seq(1, 8)], ok. -bsbs_1(0) -> - BinSize = 32+8, - io:format("A: ~p BinSize: ~p", [0,BinSize]), - Bin = binary_to_term(<<131,$M,5:32,0,0,0,0,0,0>>), - BinSize = bit_size(Bin); bsbs_1(A) -> BinSize = 32+A, io:format("A: ~p BinSize: ~p", [A,BinSize]), |