diff options
author | Erlang/OTP <[email protected]> | 2017-09-13 10:36:07 +0200 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2017-09-13 10:36:07 +0200 |
commit | a4cfcca78c83540b18786c92b1a3cf5d4ed15c2a (patch) | |
tree | f06982434a2856ce404de29d2ccceb064005b4c0 /erts/emulator | |
parent | 6f09e2fe50a614fcc368c17410a23498f0cc2d6a (diff) | |
parent | 44a83c8860bbd00878c720a7b9d940b4630bab8a (diff) | |
download | otp-a4cfcca78c83540b18786c92b1a3cf5d4ed15c2a.tar.gz otp-a4cfcca78c83540b18786c92b1a3cf5d4ed15c2a.tar.bz2 otp-a4cfcca78c83540b18786c92b1a3cf5d4ed15c2a.zip |
Merge branch 'sverker/20/binary_to_atom-utf8-crash/ERL-474/OTP-14590' into maint-20
* sverker/20/binary_to_atom-utf8-crash/ERL-474/OTP-14590:
erts: Fix crash in binary_to_atom/term for invalid utf8
Diffstat (limited to 'erts/emulator')
-rw-r--r-- | erts/emulator/beam/atom.c | 2 | ||||
-rw-r--r-- | erts/emulator/test/bif_SUITE.erl | 2 | ||||
-rw-r--r-- | erts/emulator/test/binary_SUITE.erl | 3 |
3 files changed, 6 insertions, 1 deletions
diff --git a/erts/emulator/beam/atom.c b/erts/emulator/beam/atom.c index 2055c29190..b8b34f25b4 100644 --- a/erts/emulator/beam/atom.c +++ b/erts/emulator/beam/atom.c @@ -138,7 +138,7 @@ atom_hash(Atom* obj) while(len--) { v = *p++; /* latin1 clutch for r16 */ - if ((v & 0xFE) == 0xC2 && (*p & 0xC0) == 0x80) { + if (len && (v & 0xFE) == 0xC2 && (*p & 0xC0) == 0x80) { v = (v << 6) | (*p & 0x3F); p++; len--; } diff --git a/erts/emulator/test/bif_SUITE.erl b/erts/emulator/test/bif_SUITE.erl index 339c827602..64ee1e58d5 100644 --- a/erts/emulator/test/bif_SUITE.erl +++ b/erts/emulator/test/bif_SUITE.erl @@ -503,6 +503,8 @@ binary_to_atom(Config) when is_list(Config) -> ?BADARG(binary_to_atom(id(<<255>>), utf8)), ?BADARG(binary_to_atom(id(<<255,0>>), utf8)), ?BADARG(binary_to_atom(id(<<16#C0,16#80>>), utf8)), %Overlong 0. + <<B:1/binary, _/binary>> = id(<<194, 163>>), %Truncated character ERL-474 + ?BADARG(binary_to_atom(B, utf8)), %% system_limit failures. ?SYS_LIMIT(binary_to_atom(id(<<0:512/unit:8,255>>), utf8)), diff --git a/erts/emulator/test/binary_SUITE.erl b/erts/emulator/test/binary_SUITE.erl index 4d17276e5c..61536bacd7 100644 --- a/erts/emulator/test/binary_SUITE.erl +++ b/erts/emulator/test/binary_SUITE.erl @@ -599,6 +599,9 @@ bad_binary_to_term(Config) when is_list(Config) -> %% Bad float. bad_bin_to_term(<<131,70,-1:64>>), + + %% Truncated UTF8 character (ERL-474) + bad_bin_to_term(<<131,119,1,194,163>>), ok. bad_bin_to_term(BadBin) -> |