Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
0356-kernel-stdlib-Fix-io-puts_char-error-with-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0356-kernel-stdlib-Fix-io-puts_char-error-with-invalid-bi.patch of Package erlang
From 68c12f6834a78d0d5886fe31eb59f39e0e98835f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20M=C3=A4nnchen?= <jonatan@maennchen.ch> Date: Wed, 13 Apr 2022 11:55:07 +0800 Subject: [PATCH] kernel|stdlib: Fix io:puts_char error with invalid binary Makes sure that io:puts_char/2 emits a no_translation error when called with an incomplete binary and adds detail to the resulting error message. --- lib/kernel/src/file_io_server.erl | 4 ++++ lib/stdlib/src/erl_stdlib_errors.erl | 6 ++++++ lib/stdlib/test/io_SUITE.erl | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/lib/kernel/src/file_io_server.erl b/lib/kernel/src/file_io_server.erl index 691fc00b14..57e3e87106 100644 --- a/lib/kernel/src/file_io_server.erl +++ b/lib/kernel/src/file_io_server.erl @@ -443,6 +443,10 @@ put_chars(Chars, InEncoding, #state{handle=Handle, unic=OutEncoding}=State) -> {reply,Reply,NewState} end; {error,_,_} -> + {stop,no_translation, + {error,{no_translation, InEncoding, OutEncoding}}, + NewState}; + {incomplete,_,_} -> {stop,no_translation, {error,{no_translation, InEncoding, OutEncoding}}, NewState} diff --git a/lib/stdlib/src/erl_stdlib_errors.erl b/lib/stdlib/src/erl_stdlib_errors.erl index e625d53852..3298ee0f95 100644 --- a/lib/stdlib/src/erl_stdlib_errors.erl +++ b/lib/stdlib/src/erl_stdlib_errors.erl @@ -399,6 +399,12 @@ format_unicode_error(characters_to_nfkd_list, [_]) -> unicode_char_data(Chars) -> try unicode:characters_to_binary(Chars) of + {error,_,_} -> + bad_char_data; + + {incomplete,_,_} -> + bad_char_data; + _ -> [] catch diff --git a/lib/stdlib/test/io_SUITE.erl b/lib/stdlib/test/io_SUITE.erl index cabde512d3..36d89c14ed 100644 --- a/lib/stdlib/test/io_SUITE.erl +++ b/lib/stdlib/test/io_SUITE.erl @@ -3004,6 +3004,11 @@ error_info(Config) -> Dev end, + UnicodeDev = fun() -> + {ok, Dev} = file:open(TmpFile, [read, write, {encoding, unicode}]), + Dev + end, + DeadDev = spawn(fun() -> ok end), UserDev = fun() -> whereis(user) end, @@ -3025,6 +3030,8 @@ error_info(Config) -> {put_chars,["test"], [{gl,FullDev()},{general,"no space left on device"}]}, {put_chars,[Latin1Dev(),"Спутник-1"], [{1,"transcode"}]}, {put_chars,[a], [{1,"not valid character data"}]}, + {put_chars,[UnicodeDev(), <<222>>], [{1,"transcode"}]}, + {put_chars,[<<1:1>>], [{1,"not valid character data"}]}, {put_chars,[UnknownDev(),"test"], [{general,"unknown error: 'Спутник-1'"}]}, {put_chars,["test"], [{gl,UnknownDev()},{general,"unknown error: 'Спутник-1'"}]}, -- 2.34.1
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