Mailing List Archive

[Bug 3504] New: file content lost after scp to same file at localhost
https://bugzilla.mindrot.org/show_bug.cgi?id=3504

Bug ID: 3504
Summary: file content lost after scp to same file at localhost
Product: Portable OpenSSH
Version: 8.7p1
Hardware: amd64
OS: Linux
Status: NEW
Severity: major
Priority: P5
Component: scp
Assignee: unassigned-bugs@mindrot.org
Reporter: sthiell@stanford.edu

It looks like that when scp is using the SFTP protocol (the default
now), the following use case doesn't work anymore.

Reproducer:

$ echo bar > /tmp/foo
$ cat /tmp/foo
bar
$ scp /tmp/foo localhost:/tmp/foo
foo
0% 0 0.0KB/s --:-- ETA

Then, data in /tmp/foo is lost:

$ cat /tmp/foo
$

It looks like sftp opens the destination file with O_TRUNC which is
different than with the legacy SCP, which works as expected:

$ echo bar > /tmp/foo
$ scp -O /tmp/foo localhost:/tmp/foo
foo
100% 4 2.6KB/s 00:00
$ cat /tmp/foo
bar

--
You are receiving this mail because:
You are watching the assignee of the bug.
_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-bugs