Ticket #71 (closed defect)
libssh2_scp_* do not handle whitespace in file names
|Reported by:||heiner0||Owned by:||bagder|
it seems that some libssh2 SCP functions do not correctly handle
whitespace in file names. When trying to copy a file named "with blanks"
using libssh2_scp_recv() I get an error message.
The reason is that libssh2 builds a "scp" command line that will be
run on the remote side, but does not take care to quote the file
name. It runs the equivalent of the following "ssh" command:
scp -f with blanks
instead of (note the quotation marks):
scp -f 'with blanks'
The code causing problems is in libssh2_scp_recv():
memcpy(session->scpRecv_command, "scp -f ", sizeof("scp -f ") - 1);
memcpy(session->scpRecv_command + sizeof("scp -f ") - 1, path,
(Similar code is in libssh2_scp_send()).
Variable "path" should get correct quoting.
I attached the function shell_quotearg() that could be used for quoting
the path name.