Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:20
erlang
4651-erts-Make-list_to_atom-reject-all-negative...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 4651-erts-Make-list_to_atom-reject-all-negative-code-poin.patch of Package erlang
From 8bb74593282447353376b2728989ada311df91a0 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson <sverker@erlang.org> Date: Mon, 14 Nov 2022 22:19:30 +0100 Subject: [PATCH] erts: Make list_to_atom reject all negative code points MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit with a correct badarg exception. Symptoms: Depending on negative value either * Accepted as a code point (Value band 16#fff) 1> list_to_atom([-3900]). 'Ä' * Rejected but with a broken exception (p->freason not set) 2> catch list_to_atom([-1]). {'EXIT',{[],[]}} --- erts/emulator/beam/utils.c | 12 ++++++------ erts/emulator/test/bif_SUITE.erl | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c index d7116bd2c3..4bfc99dd75 100644 --- a/erts/emulator/beam/utils.c +++ b/erts/emulator/beam/utils.c @@ -3648,7 +3648,7 @@ erts_unicode_list_to_buf(Eterm list, byte *buf, Sint len, Sint* written) { Eterm* listptr; Sint sz = 0; - Sint val; + Uint val; int res; while (1) { @@ -3671,8 +3671,8 @@ erts_unicode_list_to_buf(Eterm list, byte *buf, Sint len, Sint* written) res = -1; break; } - val = signed_val(CAR(listptr)); - if (0 <= val && val < 0x80) { + val = (Uint) signed_val(CAR(listptr)); + if (val < 0x80) { buf[sz] = val; sz++; } else if (val < 0x800) { @@ -3721,13 +3721,13 @@ erts_unicode_list_to_buf_len(Eterm list) listptr = list_val(list); while (1) { - Sint val; + Uint val; if (is_not_small(CAR(listptr))) { return -1; } - val = signed_val(CAR(listptr)); - if (0 <= val && val < 0x80) { + val = (Uint) signed_val(CAR(listptr)); + if (val < 0x80) { sz++; } else if (val < 0x800) { sz += 2; diff --git a/erts/emulator/test/bif_SUITE.erl b/erts/emulator/test/bif_SUITE.erl index 04b7f2de15..aca0174560 100644 --- a/erts/emulator/test/bif_SUITE.erl +++ b/erts/emulator/test/bif_SUITE.erl @@ -380,6 +380,9 @@ list_to_utf8_atom(Config) when is_list(Config) -> _ = atom_roundtrip([16#1000]), _ = atom_roundtrip([16#10FFFF]), atom_badarg([16#110000]), + + atom_badarg([-1]), + [atom_badarg([(-1 bsl N) + $A]) || N <- lists:seq(8,16)], ok. atom_roundtrip(String) -> -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor