diff options
author | Björn Gustavsson <[email protected]> | 2011-06-08 07:29:18 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2011-08-03 11:24:52 +0200 |
commit | 903be1a669f9a32858e08f631fabffc00861e739 (patch) | |
tree | dfe2e5003b9be52ae5ae53be8770520d5a209cf1 /erts/emulator/test | |
parent | 2d30edeb73119bbbcf3622e5c163552c10df0861 (diff) | |
download | otp-903be1a669f9a32858e08f631fabffc00861e739.tar.gz otp-903be1a669f9a32858e08f631fabffc00861e739.tar.bz2 otp-903be1a669f9a32858e08f631fabffc00861e739.zip |
Fix binary construction with huge literal sizes
Constructing binaries using the bit syntax with literals sizes
that would not fit in an Uint will either cause an emulator crash
or the loading to be aborted.
Use the new TAG_o tag introduced in the previous commit to make sure
that the attempt to create huge binary literals will generate a
system_limit exception at run-time.
Diffstat (limited to 'erts/emulator/test')
-rw-r--r-- | erts/emulator/test/bs_construct_SUITE.erl | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/erts/emulator/test/bs_construct_SUITE.erl b/erts/emulator/test/bs_construct_SUITE.erl index ef5940d748..7fdf36711b 100644 --- a/erts/emulator/test/bs_construct_SUITE.erl +++ b/erts/emulator/test/bs_construct_SUITE.erl @@ -570,6 +570,10 @@ system_limit(Config) when is_list(Config) -> ?line {'EXIT',{system_limit,_}} = (catch <<(id(<<>>))/binary,0:(id(1 bsl 100))>>), + %% Would fail to load. + ?line {'EXIT',{system_limit,_}} = (catch <<0:(1 bsl 67)>>), + ?line {'EXIT',{system_limit,_}} = (catch <<0:((1 bsl 64)+1)>>), + case WordSize of 4 -> system_limit_32(); @@ -586,6 +590,14 @@ system_limit_32() -> ?line {'EXIT',{system_limit,_}} = (catch <<0:(id(8)),42:536870912/unit:8>>), ?line {'EXIT',{system_limit,_}} = (catch <<0:(id(8)),42:(id(536870912))/unit:8>>), + + %% The size would be silently truncated, resulting in a crash. + ?line {'EXIT',{system_limit,_}} = (catch <<0:(1 bsl 35)>>), + ?line {'EXIT',{system_limit,_}} = (catch <<0:((1 bsl 32)+1)>>), + + %% Would fail to load. + ?line {'EXIT',{system_limit,_}} = (catch <<0:(1 bsl 43)>>), + ?line {'EXIT',{system_limit,_}} = (catch <<0:((1 bsl 40)+1)>>), ok. badarg(Config) when is_list(Config) -> |