Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/ssh/src/ssh_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ these messages are handled by
[handle_ssh_msg/2](`c:ssh_client_channel:handle_ssh_msg/2`).
""".

-compile([{nowarn_possibly_unsafe_function, {erlang, list_to_atom, 1}}]).


-include_lib("kernel/include/logger.hrl").

Expand Down Expand Up @@ -1621,7 +1621,10 @@ pty_default_dimensions(Dimension, TermData) ->
N when is_integer(N), N > 0 ->
{N, 0};
_ ->
PixelDim = list_to_atom("pixel_" ++ atom_to_list(Dimension)),
PixelDim = case Dimension of
width -> pixel_width;
height -> pixel_height
end,
case proplists:get_value(PixelDim, TermData, 0) of
N when is_integer(N), N > 0 ->
{0, N};
Expand Down
3 changes: 3 additions & 0 deletions lib/ssh/src/ssh_options.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
-module(ssh_options).
-moduledoc false.

%% file:consult/1 can create atoms from file content. This is acceptable
%% here because the file path comes from the daemon operator's dh_gex_groups
%% configuration — not from wire data.
-compile([{nowarn_possibly_unsafe_function, {file, consult, 1}}]).

-include("ssh.hrl").
Expand Down
6 changes: 3 additions & 3 deletions lib/ssh/src/ssh_transport.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
-module(ssh_transport).
-moduledoc false.

-compile([{nowarn_possibly_unsafe_function, {erlang, binary_to_atom, 1}}]).


-include_lib("public_key/include/public_key.hrl").
-include_lib("kernel/include/inet.hrl").
Expand Down Expand Up @@ -2280,7 +2280,7 @@ valid_key_sha_alg(_, _, _) -> false.

valid_key_sha_alg_ec(OID, Alg) when is_tuple(OID) ->
{SshCurveType, _} = ssh_message:oid2ssh_curvename(OID),
Alg == binary_to_atom(SshCurveType);
Alg == binary_to_existing_atom(SshCurveType);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point, can you be sure that all the existing/valid SshCurveType values have already been "atomized"? That is, can you be sure that the valid atoms exist?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are only 5 SshCurveType binaries which can be returned by ssh_message:oid2ssh_curvename/1. all corresponding atoms are defined in ssh_transport:supported_algorithms/1 and ssh_transport:sha/1, and loaded to atom table upon loading ssh_transport beam module.

Copy link
Copy Markdown
Contributor

@juhlig juhlig Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... but in that case, if you know all the binaries you can get from that function and also the atoms they map to, why is this done through binary_to_existing_atom, instead of having a function like ssh_curvename_to_atom that turns one into the other, either in this module or in ssh_message?

valid_key_sha_alg_ec(_, _) -> false.


Expand All @@ -2291,7 +2291,7 @@ public_algo(#'RSAPublicKey'{}) -> 'ssh-rsa'; % FIXME: Not right with draft-cu
public_algo({_, #'Dss-Parms'{}}) -> 'ssh-dss';
public_algo({#'ECPoint'{},{namedCurve,OID}}) when is_tuple(OID) ->
{SshCurveType, _} = ssh_message:oid2ssh_curvename(OID),
binary_to_atom(SshCurveType).
binary_to_existing_atom(SshCurveType).
Comment thread
u3s marked this conversation as resolved.


sha('ssh-rsa') -> sha;
Expand Down
Loading