www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

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


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.



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.

libssh2-devel mailing list

Received on 2008-05-08

the libssh2 team