aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKjell Winblad <[email protected]>2019-01-29 12:33:19 +0100
committerKjell Winblad <[email protected]>2019-01-30 14:38:25 +0100
commit1df3d85824601e3c07d12ca9811866c2ef334e76 (patch)
treee6de0e195b436e69aee3af23ec6a890d43636ab4 /lib
parent71e7b98034ac00d9ee5428ed0602646e29851a29 (diff)
downloadotp-1df3d85824601e3c07d12ca9811866c2ef334e76.tar.gz
otp-1df3d85824601e3c07d12ca9811866c2ef334e76.tar.bz2
otp-1df3d85824601e3c07d12ca9811866c2ef334e76.zip
Fix bug in binary:encode_unsigned causing a read of uninitialized memory
The bug could be seen by running the test that is added by this commit in a valgrind enabled emulator. Co-authored-by: John Högberg <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r--lib/stdlib/test/binary_module_SUITE.erl15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/stdlib/test/binary_module_SUITE.erl b/lib/stdlib/test/binary_module_SUITE.erl
index c5cfea5e9e..e0811f19cf 100644
--- a/lib/stdlib/test/binary_module_SUITE.erl
+++ b/lib/stdlib/test/binary_module_SUITE.erl
@@ -22,7 +22,8 @@
-export([all/0, suite/0,
interesting/1,scope_return/1,random_ref_comp/1,random_ref_sr_comp/1,
random_ref_fla_comp/1,parts/1, bin_to_list/1, list_to_bin/1,
- copy/1, referenced/1,guard/1,encode_decode/1,badargs/1,longest_common_trap/1]).
+ copy/1, referenced/1,guard/1,encode_decode/1,badargs/1,longest_common_trap/1,
+ check_no_invalid_read_bug/1]).
-export([random_number/1, make_unaligned/1]).
@@ -36,7 +37,7 @@ all() ->
[scope_return,interesting, random_ref_fla_comp, random_ref_sr_comp,
random_ref_comp, parts, bin_to_list, list_to_bin, copy,
referenced, guard, encode_decode, badargs,
- longest_common_trap].
+ longest_common_trap, check_no_invalid_read_bug].
-define(MASK_ERROR(EXPR),mask_error((catch (EXPR)))).
@@ -1361,3 +1362,13 @@ make_unaligned2(Bin0) when is_binary(Bin0) ->
Bin.
id(I) -> I.
+
+check_no_invalid_read_bug(Config) when is_list(Config) ->
+ check_no_invalid_read_bug(24);
+check_no_invalid_read_bug(60) ->
+ ok;
+check_no_invalid_read_bug(I) ->
+ N = 1 bsl I,
+ binary:encode_unsigned(N+N),
+ binary:encode_unsigned(N+N, little),
+ check_no_invalid_read_bug(I+1).