Bug 1230 - filename escaping of brackets in sftp
Summary: filename escaping of brackets in sftp
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp (show other bugs)
Version: 4.3p2
Hardware: PPC Mac OS X
: P2 normal
Assignee: Damien Miller
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-16 21:50 AEST by Stephan Kleisinger
Modified: 2008-04-04 09:56 AEDT (History)
0 users

See Also:


Attachments
process_put: check pathname even if glob does not match (1.32 KB, patch)
2008-01-20 11:31 AEDT, Damien Miller
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Kleisinger 2006-09-16 21:50:37 AEST
ist's impossible to escape a filename that contains brackets ([]) with quotes for the put command.

Steps to Reproduce:
  1. create a file with filename: [eztv]
  2. try to upload with sftp put

Actual Results:
sftp> lls
[eztv]
sftp> put '[eztv]'
File "[eztv]" not found.
sftp> put "[eztv]"
File "[eztv]" not found.
sftp> put [eztv]
File "[eztv]" not found.
sftp> put \[eztv\]
Uploading [eztv] to /private/tmp/[eztv]
[eztv]                                                        100%    4     0.0KB/s   00:00    
sftp> put \[abcdefg\]
File "\\[abcdefg\\]" not found.

Expected Results: 
 the first 3 commands should work and react the same way
 the 4. command may work??
 the 5. command may emit: File "[abcdefg]" not found.  

Occurs on:
- OpenSSH_4.2p1, OpenSSL 0.9.7i 14 Oct 2005
  Mac OS X 10.4.7 (PowerPC)
- OpenSSH_4.3p2, OpenSSL 0.9.8a 11 Oct 2005
   Linux octopus 2.6.17-1.2157_FC5smp #1 SMP Tue Jul 11 23:24:16 EDT 2006 i686 i686 i386 GNU/Linux
- OpenSSH_4.3p2, OpenSSL 0.9.7i 14 Oct 2005
   Mac OS X 10.4.7 (PowerPC)

Additional information:
- It seems to be impossible to use a filename that contains brackets AND spaces e.g. [ez tv]
- this bug is relevant, because some guis use sftp. e.g. Fugu 1.2.0 
   http://rsug.itd.umich.edu/software/fugu/
Comment 1 Damien Miller 2008-01-20 11:31:11 AEDT
Created attachment 1445 [details]
process_put: check pathname even if glob does not match

The recently committed argument parser changes together with this additional patch make all your test cases pass:

sftp> put '[eztv]'
Uploading [eztv] to /tmp/xxxx/[eztv]
[eztv]                                        100%    0     0.0KB/s   00:00
sftp> put "[eztv]"
Uploading [eztv] to /tmp/xxxx/[eztv]
[eztv]                                        100%    0     0.0KB/s   00:00
sftp> put [eztv]
Uploading [eztv] to /tmp/xxxx/[eztv]
[eztv]                                        100%    0     0.0KB/s   00:00
sftp> put \[eztv\]
Uploading [eztv] to /tmp/xxxx/[eztv]
[eztv]                                        100%    0     0.0KB/s   00:00
sftp> put \[abcdefg\]
stat [abcdefg]: No such file or directory

I'll apply this fix now, so it will be in OpenSSH 4.8. Thanks indeed for the detailed bug report and test cases.
Comment 2 Damien Miller 2008-01-20 11:38:48 AEDT
fix applied
Comment 3 Damien Miller 2008-04-04 09:56:07 AEDT
Close resolved bugs after release.