Skip to content

Commit 99979ac

Browse files
author
Erlang/OTP
committed
Merge branch 'kuba/maint-25/kuba/ssh/simplify_message_decoding/OTP-19582' into maint-27
* kuba/maint-25/kuba/ssh/simplify_message_decoding/OTP-19582: ssh: avoid using unicode module when not needed ssh: reduce error data processed upon unicode to list conversion
2 parents 6996e71 + 289d572 commit 99979ac

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/ssh/src/ssh_message.erl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
ucl(B) ->
5050
try unicode:characters_to_list(B) of
5151
L when is_list(L) -> L;
52-
{error,_Matched,Rest} -> throw({error,{bad_unicode,Rest}})
52+
{error,_Matched,_Rest} -> throw({error,bad_unicode})
5353
catch
5454
_:_ -> throw({error,bad_unicode})
5555
end.
@@ -209,12 +209,12 @@ encode(#ssh_msg_disconnect{
209209
encode(#ssh_msg_service_request{
210210
name = Service
211211
}) ->
212-
<<?Ebyte(?SSH_MSG_SERVICE_REQUEST), ?Estring_utf8(Service)>>;
212+
<<?Ebyte(?SSH_MSG_SERVICE_REQUEST), ?Estring(Service)>>;
213213

214214
encode(#ssh_msg_service_accept{
215215
name = Service
216216
}) ->
217-
<<?Ebyte(?SSH_MSG_SERVICE_ACCEPT), ?Estring_utf8(Service)>>;
217+
<<?Ebyte(?SSH_MSG_SERVICE_ACCEPT), ?Estring(Service)>>;
218218

219219
encode(#ssh_msg_ext_info{
220220
nr_extensions = N,
@@ -377,7 +377,7 @@ decode(<<?BYTE(?SSH_MSG_CHANNEL_REQUEST), ?UINT32(Recipient),
377377
try
378378
#ssh_msg_channel_request{
379379
recipient_channel = Recipient,
380-
request_type = ?unicode_list(RequestType),
380+
request_type = binary:bin_to_list(RequestType),
381381
want_reply = erl_boolean(Bool),
382382
data = Data
383383
}
@@ -407,16 +407,16 @@ decode(<<?BYTE(?SSH_MSG_USERAUTH_REQUEST),
407407
Data/binary>>) ->
408408
#ssh_msg_userauth_request{
409409
user = ?unicode_list(User),
410-
service = ?unicode_list(Service),
411-
method = ?unicode_list(Method),
410+
service = binary:bin_to_list(Service),
411+
method = binary:bin_to_list(Method),
412412
data = Data
413413
};
414414

415415
decode(<<?BYTE(?SSH_MSG_USERAUTH_FAILURE),
416416
?DEC_BIN(Auths,__0),
417417
?BYTE(Bool)>>) ->
418418
#ssh_msg_userauth_failure {
419-
authentications = ?unicode_list(Auths),
419+
authentications = binary:bin_to_list(Auths),
420420
partial_success = erl_boolean(Bool)
421421
};
422422

@@ -530,12 +530,12 @@ decode(<<"ecdh",?BYTE(?SSH_MSG_KEX_ECDH_REPLY),
530530

531531
decode(<<?SSH_MSG_SERVICE_REQUEST, ?DEC_BIN(Service,__0)>>) ->
532532
#ssh_msg_service_request{
533-
name = ?unicode_list(Service)
533+
name = binary:bin_to_list(Service)
534534
};
535535

536536
decode(<<?SSH_MSG_SERVICE_ACCEPT, ?DEC_BIN(Service,__0)>>) ->
537537
#ssh_msg_service_accept{
538-
name = ?unicode_list(Service)
538+
name = binary:bin_to_list(Service)
539539
};
540540

541541
decode(<<?BYTE(?SSH_MSG_DISCONNECT), ?UINT32(Code), ?DEC_BIN(Desc,__0), ?DEC_BIN(Lang,__1)>>) ->

0 commit comments

Comments
 (0)