Subject: [libssh2] [ libssh2-Bugs-1960894 ] libssh2_scp_* do not handle whitespace in file names

[libssh2] [ libssh2-Bugs-1960894 ] libssh2_scp_* do not handle whitespace in file names

From: <>
Date: Thu, 21 Aug 2008 16:58:38 +0000

Bugs item #1960894, was opened at 2008-05-09 09:50
Message generated for change (Comment added) made by heiner0
You can respond by visiting:

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Heiner (heiner0)
Assigned to: Nobody/Anonymous (nobody)
Summary: libssh2_scp_* do not handle whitespace in file names

Initial Comment:
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.


>Comment By: Heiner (heiner0)
Date: 2008-08-21 16:58

Logged In: YES
Originator: YES

The shell_quotearg() function had problems when the login shell of the
user was the C-Shell (csh). The new function works with CSH as well.
It includes a small test program: cc -DMAIN -o qtest shell_quotearg.c;
./qtest "someone's test"

File Added: shell_quotearg.c


You can respond by visiting:

This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
libssh2-devel mailing list
Received on 2008-08-21