Bug 1302 - scp failes to copy a file with newline
Summary: scp failes to copy a file with newline
Status: CLOSED DUPLICATE of bug 891
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: scp (show other bugs)
Version: 4.3p2
Hardware: ix86 Linux
: P2 minor
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-04 20:12 AEST by Zdenek Pytela
Modified: 2008-04-04 09:59 AEDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Pytela 2007-04-04 20:12:49 AEST
When copying a directory (scp -r) with a file containing \n
copying stops with cryptic message
protocol error: expected control record
Debug mode is more verbose about the cause:

Sink: : skipping, filename contains a newline
protocol error: expected control record
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
...
debug1: Exit status 1

First, newline is legal (although weird) character for a file. Second, the message doesn't help to user find what happened. Third, the copying is not skipping one file, but stops at all.
Comment 1 Darren Tucker 2007-04-04 21:26:25 AEST
This is basically an unfixable limitation of the scp protocol.  The header pretty much just "filename size modes\n" and when the filename has a newline in it the protocol breaks.

You could escape the newlines (which I think I have a patch for somewhere) but then the complaint becomes "scp changed my filename".

About the best that could be done is to bail or skip the file with a "don't do that, then" error when someone tries to copy a file with a newline embedded in the name.
Comment 2 Damien Miller 2007-05-17 22:57:33 AEST

*** This bug has been marked as a duplicate of bug 891 ***
Comment 3 Damien Miller 2008-04-04 09:59:04 AEDT
Close resolved bugs after release.