aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2012-08-30 09:33:52 +0200
committerIngela Anderton Andin <[email protected]>2012-08-30 09:33:52 +0200
commit94f6c68ff4a46c69be0030aff553d6db92f29a35 (patch)
tree690aab5afb85bb98968a4349c0e38d4eaa5e8535 /lib/ssh
parentfcbb937b9e34e97529aa28e994c05c2d03dc89cd (diff)
parent1429ac4b0a76c73224382a32ecd28ee89f5327ce (diff)
downloadotp-94f6c68ff4a46c69be0030aff553d6db92f29a35.tar.gz
otp-94f6c68ff4a46c69be0030aff553d6db92f29a35.tar.bz2
otp-94f6c68ff4a46c69be0030aff553d6db92f29a35.zip
Merge branch 'ia/ssh/ignore-incorrect-lines-in-auth_keys-and-known_hosts' into maint
* ia/ssh/ignore-incorrect-lines-in-auth_keys-and-known_hosts: ssh: Increase robustness
Diffstat (limited to 'lib/ssh')
-rw-r--r--lib/ssh/src/ssh.appup.src2
-rw-r--r--lib/ssh/src/ssh_file.erl11
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/ssh/src/ssh.appup.src b/lib/ssh/src/ssh.appup.src
index 6967a0f464..d08dbafc32 100644
--- a/lib/ssh/src/ssh.appup.src
+++ b/lib/ssh/src/ssh.appup.src
@@ -24,6 +24,7 @@
{load_module, ssh_connection_manager, soft_purge, soft_purge, []},
{load_module, ssh_auth, soft_purge, soft_purge, []},
{load_module, ssh_channel, soft_purge, soft_purge, []},
+ {load_module, ssh_file, soft_purge, soft_purge, []}]},
{load_module, ssh, soft_purge, soft_purge, []}]},
{<<"2.0\\.*">>, [{restart_application, ssh}]},
{<<"1\\.*">>, [{restart_application, ssh}]}
@@ -34,6 +35,7 @@
{load_module, ssh_connection_manager, soft_purge, soft_purge, []},
{load_module, ssh_auth, soft_purge, soft_purge, []},
{load_module, ssh_channel, soft_purge, soft_purge, []},
+ {load_module, ssh_file, soft_purge, soft_purge, []}]},
{load_module, ssh, soft_purge, soft_purge, []}]},
{<<"2.0\\.*">>, [{restart_application, ssh}]},
{<<"1\\.*">>, [{restart_application, ssh}]}
diff --git a/lib/ssh/src/ssh_file.erl b/lib/ssh/src/ssh_file.erl
index d05fa8e09a..a6b82a7a13 100644
--- a/lib/ssh/src/ssh_file.erl
+++ b/lib/ssh/src/ssh_file.erl
@@ -232,7 +232,7 @@ lookup_host_key_fd(Fd, Host, KeyType) ->
eof ->
{error, not_found};
Line ->
- case public_key:ssh_decode(Line, known_hosts) of
+ case ssh_decode_line(Line, known_hosts) of
[{Key, Attributes}] ->
handle_host(Fd, Host, proplists:get_value(hostnames, Attributes), Key, KeyType);
[] ->
@@ -240,6 +240,13 @@ lookup_host_key_fd(Fd, Host, KeyType) ->
end
end.
+ssh_decode_line(Line, Type) ->
+ try
+ public_key:ssh_decode(Line, Type)
+ catch _:_ ->
+ []
+ end.
+
handle_host(Fd, Host, HostList, Key, KeyType) ->
Host1 = host_name(Host),
case lists:member(Host1, HostList) and key_match(Key, KeyType) of
@@ -285,7 +292,7 @@ lookup_user_key_fd(Fd, Key) ->
eof ->
{error, not_found};
Line ->
- case public_key:ssh_decode(Line, auth_keys) of
+ case ssh_decode_line(Line, auth_keys) of
[{AuthKey, _}] ->
case is_auth_key(Key, AuthKey) of
true ->