Subject: [libssh2] libssh2_scp_*: Whitespace in file names are not handled correctly

[libssh2] libssh2_scp_*: Whitespace in file names are not handled correctly

From: Heiner Steven <heiner.steven_at_nexgo.de>
Date: Thu, 08 May 2008 09:57:16 +0200

Hello,

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,
            path_len);

     (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.

Greetings

Heiner

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel

Received on 2008-05-08