Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Using the Ganymed SSH2 client (build 210 from here http://www.ganymed.ethz.ch/ssh2/) uploading a file to an instance of Mina SSHD causes the following exception:
java.io.IOException: Expected a C message but got 'E'
at org.apache.sshd.server.command.ScpCommand.writeFile(ScpCommand.java:299)
at org.apache.sshd.server.command.ScpCommand.run(ScpCommand.java:174)
at java.lang.Thread.run(Thread.java:662)
Further investigation into the issue reveals that the Ganymed client ends the C command sequence with an E command. Looking at the code for ScpCommand run() method I notice the following switch statement:
switch (c)
{ case -1: return; case 'D': isDir = true; case 'C': case 'E': line = ((char) c) + readLine(); break; default: //a real ack that has been acted upon already continue; }The E command is part of the fall through for C and D command where the respective handlers for these commands assert that a command is either a C or D. If either of these handlers receive an E then an exception is raised.
Changing the switch statement to prevent the E from reaching the writeFile or writeDir as follows remedies the issue for me:
switch (c)
{ case -1: return; case 'D': isDir = true; case 'C': line = ((char) c) + readLine(); break; case 'E': readLine(); // consume remainder of line return; default: //a real ack that has been acted upon already continue; }I'm using a version compiled from the current SVN head revision 1132372