Bugs item #1960894, was opened at 2008-05-09 11:50 Message generated for change (Comment added) made by bagder You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=703942&aid=1960894&group_id=125852
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: SCP Group: None Status: Open >Resolution: Accepted Priority: 5 Private: No Submitted By: Heiner (heiner0) >Assigned to: Daniel Stenberg (bagder) 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, 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. ---------------------------------------------------------------------- >Comment By: Daniel Stenberg (bagder) Date: 2009-03-16 00:25 Message: If you tell me your real name, I'll give you the proper credit in the changelogs etc! ---------------------------------------------------------------------- Comment By: Heiner (heiner0) Date: 2008-11-07 09:53 Message: [This comment is the same as request 2233372] The attached patch fixes [1960894] libssh2_scp_* do not handle whitespace in file names It introduces a new (private) function libssh2_shell_quotearg() for "quoting" a shell command argument (e.g. a file name). Example: one two gets converted to 'one two' (note the single quotation marks). The quoting style ensures that the results work with both Bourne Shell derivates (sh, ksh, ksh93, bash, zsh) and C-Shell dialects (csh, tcsh). The new (private) macro libssh2_shell_quotedsize() calculates the maximum size a quoted string can have; this is useful for allocating a memory buffer for the results. I've tested the code with Linux: bash, ksh93, tcsh Solaris: sh, bash, csh File Added: shellquote.patch ---------------------------------------------------------------------- Comment By: Daniel Stenberg (bagder) Date: 2008-09-29 15:47 Message: So can you please submit a complete patch that makes use of the code you suggest? ---------------------------------------------------------------------- Comment By: Heiner (heiner0) Date: 2008-08-21 18:58 Message: Logged In: YES user_id=1568315 Originator: YES The shell_quotearg() function had problems when the login shell of the remote 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: https://sourceforge.net/tracker/?func=detail&atid=703942&aid=1960894&group_id=125852 ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ libssh2-devel mailing list libssh2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libssh2-devel