diff options
author | Hans Nilsson <hans@erlang.org> | 2016-06-17 14:49:04 +0200 |
---|---|---|
committer | Hans Nilsson <hans@erlang.org> | 2016-06-22 12:31:32 +0200 |
commit | d68b279981496c5293746524e00ff77fd8a8b84c (patch) | |
tree | b9475997148f4b6c4424d260d91aee23eef362fe /lib | |
parent | c66f6df0678362ce09558af1981473b0b8d82baf (diff) | |
download | otp-d68b279981496c5293746524e00ff77fd8a8b84c.tar.gz otp-d68b279981496c5293746524e00ff77fd8a8b84c.tar.bz2 otp-d68b279981496c5293746524e00ff77fd8a8b84c.zip |
ssh: Fix a hazard bug in ssh_auth
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ssh/src/ssh_io.erl | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/ssh/src/ssh_io.erl b/lib/ssh/src/ssh_io.erl index 6be5ea25bb..5e335c2063 100644 --- a/lib/ssh/src/ssh_io.erl +++ b/lib/ssh/src/ssh_io.erl @@ -31,7 +31,7 @@ read_line(Prompt, Ssh) -> format("~s", [listify(Prompt)]), proplists:get_value(user_pid, Ssh) ! {self(), question}, receive - Answer -> + Answer when is_list(Answer) -> Answer end. @@ -44,7 +44,7 @@ yes_no(Prompt, Ssh) -> y -> yes; n -> no; - Answer -> + Answer when is_list(Answer) -> case trim(Answer) of "y" -> yes; "n" -> no; @@ -62,20 +62,24 @@ read_password(Prompt, Opts) when is_list(Opts) -> format("~s", [listify(Prompt)]), proplists:get_value(user_pid, Opts) ! {self(), user_password}, receive - "" -> - read_password(Prompt, Opts); - Answer -> - Answer + Answer when is_list(Answer) -> + case trim(Answer) of + "" -> + read_password(Prompt, Opts); + Pwd -> + Pwd + end end. +format(Fmt, Args) -> + io:format(Fmt, Args). + +%%%================================================================ listify(A) when is_atom(A) -> atom_to_list(A); listify(L) when is_list(L) -> L; listify(B) when is_binary(B) -> binary_to_list(B). -format(Fmt, Args) -> - io:format(Fmt, Args). - trim(Line) when is_list(Line) -> lists:reverse(trim1(lists:reverse(trim1(Line)))); |