diff options
author | djm@openbsd.org <djm@openbsd.org> | 2022-05-13 08:31:50 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2022-05-13 09:00:56 +0200 |
commit | 56a0697fe079ff3e1ba30a2d5c26b5e45f7b71f8 (patch) | |
tree | dfdc7bf1433d7bd162e70d08b023f429ca8881e7 /scp.c | |
parent | upstream: Remove errant apostrophe. From haruyama at queen-ml org. (diff) | |
download | openssh-56a0697fe079ff3e1ba30a2d5c26b5e45f7b71f8.tar.xz openssh-56a0697fe079ff3e1ba30a2d5c26b5e45f7b71f8.zip |
upstream: arrange for scp, when in sftp mode, to not ftruncate(3) files
early
previous behavious of unconditionally truncating the destination file
would cause "scp ~/foo localhost:" and "scp localhost:foo ~/" to
delete all the contents of their destination.
spotted by solene@ sthen@, also bz3431; ok dtucker@
OpenBSD-Commit-ID: ca39fdd39e0ec1466b9666f15cbcfddea6aaa179
Diffstat (limited to 'scp.c')
-rw-r--r-- | scp.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: scp.c,v 1.247 2022/03/20 08:52:17 djm Exp $ */ +/* $OpenBSD: scp.c,v 1.248 2022/05/13 06:31:50 djm Exp $ */ /* * scp - secure remote copy. This is basically patched BSD rcp which * uses ssh to do the data transfer (instead of using rcmd). @@ -1311,11 +1311,11 @@ source_sftp(int argc, char *src, char *targ, struct sftp_conn *conn) if (src_is_dir && iamrecursive) { if (upload_dir(conn, src, abs_dst, pflag, - SFTP_PROGRESS_ONLY, 0, 0, 1) != 0) { + SFTP_PROGRESS_ONLY, 0, 0, 1, 1) != 0) { error("failed to upload directory %s to %s", src, targ); errs = 1; } - } else if (do_upload(conn, src, abs_dst, pflag, 0, 0) != 0) { + } else if (do_upload(conn, src, abs_dst, pflag, 0, 0, 1) != 0) { error("failed to upload file %s to %s", src, targ); errs = 1; } @@ -1552,11 +1552,11 @@ sink_sftp(int argc, char *dst, const char *src, struct sftp_conn *conn) debug("Fetching %s to %s\n", g.gl_pathv[i], abs_dst); if (globpath_is_dir(g.gl_pathv[i]) && iamrecursive) { if (download_dir(conn, g.gl_pathv[i], abs_dst, NULL, - pflag, SFTP_PROGRESS_ONLY, 0, 0, 1) == -1) + pflag, SFTP_PROGRESS_ONLY, 0, 0, 1, 1) == -1) err = -1; } else { if (do_download(conn, g.gl_pathv[i], abs_dst, NULL, - pflag, 0, 0) == -1) + pflag, 0, 0, 1) == -1) err = -1; } free(abs_dst); |