[erlang-bugs] SSH-daemon invalid column calculation at ssh_cli:delete_chars()

Alexander Demidenko alex.demidenko@REDACTED
Thu Nov 21 03:51:44 CET 2013


Hello, friends.

How can I see, in the ssh_cli.erl module, delete_chars method incorrectly
calculate variable "NewCol".

I can offer the option of a patch that fixes this problem.
The person who is responsible for supporting ssh has the discretion to take
it as it is, or can make own fix.
Tested by Erlang 16B02, ssh 2.1.8 and R15B02, ssh 2.1.1

hurd@REDACTED:~/Documents/Erlang/reports/ssh_expand_test$ cat ssh.patch
--- ssh-2.1.1/src/ssh_cli.erl 2013-10-26 14:25:26.000000000
+++ ssh-2.1.2/src/ssh_cli.erl 2013-10-26 14:18:18.000000000
@@ -311,13 +319,14 @@
     NewBufTail = nthtail(N, BufTail),
     M = move_cursor(Col + length(NewBufTail) + N, Col, Tty),
     {[NewBufTail, lists:duplicate(N, $ ) | M],
      {Buf, NewBufTail, Col}};
 delete_chars(N, {Buf, BufTail, Col}, Tty) -> % N < 0
     NewBuf = nthtail(-N, Buf),
-    NewCol = Col + N,
+    NewCol = case Col + N of V when V >= 0 -> V; _ -> 0 end,
     M1 = move_cursor(Col, NewCol, Tty),
     M2 = move_cursor(NewCol + length(BufTail) - N, NewCol, Tty),
     {[M1, BufTail, lists:duplicate(-N, $ ) | M2],
      {NewBuf, BufTail, NewCol}}.

 %%% Window change, redraw the current line (and clear out after it


I attached simple sample, where you can see this problem.
To run it, compile ssh_manager.erl and invoke "ssh_manager:start()" method
to run ssh-daemon.
Then run simple ssh-client on terminal to localhost on port 9999, and
entering the password "test".
(you need put keys in .ssh folder)
Below example show trouble with the display of available commands when you
press Tab.

At the command prompt "ssh_app:"
_____________________________________________________
1> ssh_app:
_____________________________________________________

Press tab.
_____________________________________________________
1> ssh_app:
module_info/0  module_info/1  start/2        stop/1
1> ssh_app:
_____________________________________________________

You will see the line below "module_info/0 module_info/1 start/2 stop/1,"
and below that "ssh_app:".
Everything is wonderful. Yet.

Do the following: Go to the new line (Press enter) and enter a space as
long as the input field team did not go on the line below .
_____________________________________________________
1>

_____________________________________________________

Enter "ssh_app:"

_____________________________________________________
1>
                       ssh_app:
_____________________________________________________

Press tab.
_____________________________________________________
1>
                       ssh_app:
1>
                       ssh_app:
_____________________________________________________

You will see that the tab has not worked. The string "module_info/0
module_info/1 start/2 stop/1" was not withdrawn.
This is not good.

You still can do the following: Go to the new line (press the button enter)
and enter a space as long as the input field team did not go on 2 lines
below.
_____________________________________________________
1>

_____________________________________________________

Enter "ssh_app:".
____________________________________________________
1>
                                   ssh_app:
_____________________________________________________

Press tab.

_____________________________________________________
1>

1>

                                   ssh_app:
_____________________________________________________

You will see that the tab has not worked. The string "module_info/0
module_info/1 start/2 stop/1" was not withdrawn. This is not good.

-- 
---------------------------------------------
With best regards,
Alexander.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20131121/63427093/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ssh_expand_test.tar.gz
Type: application/x-gzip
Size: 5857 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20131121/63427093/attachment.bin>


More information about the erlang-bugs mailing list