PuTTY bug scp-newline

This is a mirror. Follow this link to find the primary PuTTY web site.

Home | FAQ | Feedback | Licence | Updates | Mirrors | Keys | Links | Team
Download: Stable · Snapshot | Docs | Privacy | Changes | Wishlist

summary: PSCP in SCP mode can try to write filenames containing newlines
class: bug: This is clearly an actual problem we want fixed.
difficulty: fun: Just needs tuits, and not many of them.
priority: high: This should be fixed in the next release.
absent-in: 0.70
present-in: d07d7d66f662b670a94c58e68a083f512e57e7a8 0.71
fixed-in: 1d8b48fd22dbfd613e25eb20a3c29acb6f2abe88 (0.72)

PSCP, when it is using the SCP protocol (which is rare), can attempt to create filenames containing spurious newline characters, or wrongly complain that the server is requesting this. (This error was introduced shortly before 0.71 was released, and fixed shortly afterward.)

In most circumstances, PSCP will use the more modern SFTP protocol, which does not have this problem. The SCP protocol will only be used if the server doesn't appear to support SFTP (rare), or if the user explicitly specified the -scp option on the command line.

For instance, you might see this when copying a single file:

$ ./pscp -scp remotehost:stoat .
Keyboard-interactive authentication prompts from server:
| Password:
End of keyboard-interactive prompts from server
warning: remote host tried to write  to a file called 'stoat
'
         when we requested a file called 'stoat'.
         If this is a wildcard, consider upgrading to SSH-2 or using
         the '-unsafe' option. Renaming of this file has been disallowed.
stoat                     | 0 kB |   0.0 kB/s | ETA: 00:00:00 | 100%

Note the quote mark on a line on its own -- that shows a newline character is in the filename. In this case, PSCP knows the intended filename from the command line, so it grumbles and the local file is written out with a sensible filename. (The warning is spurious; the bug is that PSCP briefly forgot how the SCP protocol worked.)

It's worse when copying whole directories:

$ ./pscp -r -scp remotehost:dir .
Keyboard-interactive authentication prompts from server:
| Password:
End of keyboard-interactive prompts from server
warning: remote host tried to write  to a file called 'dir
'
         when we requested a file called 'dir'.
         If this is a wildcard, consider upgrading to SSH-2 or using
         the '-unsafe' option. Renaming of this file has been disallowed.
stoat
                    | 0 kB |   0.0 kB/s | ETA: 00:00:00 | 100%

Here it's created a directory called dir (without a newline), but in this Unix example, the file(s) inside it have been created with a newline in the actual filename. This is an unusual thing to have in a filename, and might confuse other tools or be difficult to delete.

In the same case on Windows, the operating system simply refuses to create a file whose name contains a newline character:

pscp: .\dir\stoat
: Cannot create file


If you want to comment on this web site, see the Feedback page.
Audit trail for this bug.
(last revision of this bug record was at 2019-03-22 20:55:50 +0000)