Mailing List Archive

[Bug 2948] implement "copy-data" sftp extension
https://bugzilla.mindrot.org/show_bug.cgi?id=2948

--- Comment #9 from Damien Miller <djm@mindrot.org> ---
Comment on attachment 3344
--> https://bugzilla.mindrot.org/attachment.cgi?id=3344
sftp server copy-data extension

looks good - some minor comments

>diff --git a/PROTOCOL b/PROTOCOL
>index f75c1c0ae5b0..04a392db33be 100644
...
>+static void
>+process_extended_copy_data(u_int32_t id)
...
>+ /* Disallow reading & writing to the same handle */
>+ if (read_handle == write_handle || read_fd < 0 || write_fd < 0) {

I think this should also check that both the read and write handles do
not refer to the same path? (use handle_to_name())

>+ status = SSH2_FX_FAILURE;
>+ } else {

nit: prefer "goto out" over nesting if/else

>+ if (lseek(read_fd, read_off, SEEK_SET) < 0) {
>+ status = errno_to_portable(errno);
>+ error("process_extended_copy_data: read_seek failed");

nit: ditto

>+ } else if (!(handle_to_flags(write_handle) & O_APPEND) &&
>+ lseek(write_fd, write_off, SEEK_SET) < 0) {
>+ status = errno_to_portable(errno);
>+ error("process_extended_copy_data: write_seek failed");

nit: prefer __func__ to manual inclusion of function name

>+ } else {
>+ /* Process the request in chunks. */
>+ while (read_len || copy_until_eof) {

nit: prefer explicit comparison against zero (i.e "read_len > 0")

>+
>+ ret = read(read_fd, buf, len);
...
>+ ret = write(write_fd, buf, len);

I think this should use atomicio here to be signal safe.

>+ if ((size_t)ret != len) {
>+ debug2("nothing at all written");
>+ status = SSH2_FX_FAILURE;
>+ break;
>+ }

this block can go away with atomicio

--
You are receiving this mail because:
You are watching the assignee of the bug.
You are watching someone on the CC list of the bug.
_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-bugs
[Bug 2948] implement "copy-data" sftp extension [ In reply to ]
https://bugzilla.mindrot.org/show_bug.cgi?id=2948

--- Comment #10 from Damien Miller <djm@mindrot.org> ---
Comment on attachment 3345
--> https://bugzilla.mindrot.org/attachment.cgi?id=3345
sftp client copy-data extension

This too looks good, minor comments:

>diff --git a/sftp-client.c b/sftp-client.c
>index 4986d6d8d291..cd2844a8585e 100644
>--- a/sftp-client.c
>+++ b/sftp-client.c
...
>+int
>+do_copy(struct sftp_conn *conn, const char *oldpath, const char *newpath)
>+{
...
>+ /* Silently return if the extension is not supported */
>+ if ((conn->exts & SFTP_EXT_COPY_DATA) == 0) {
>+ error("Server does not support copy-data extension");

This is not silent :)

>diff --git a/sftp.1 b/sftp.1
>index 0fd54cae090e..f2eae7f32790 100644
>--- a/sftp.1
>+++ b/sftp.1
...
>+.Ic lchdir , copy , chmod , chown ,

the manpage says the command is "copy", but ...

>diff --git a/sftp.c b/sftp.c
>index 7db86c2d3cf0..3288279172a9 100644
>--- a/sftp.c
>+++ b/sftp.c
...
>+ { "cp", I_COPY, REMOTE },

... it's implemented as "cp"

Either/both is fine, but it needs to be consistent of course.

--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-bugs
[Bug 2948] implement "copy-data" sftp extension [ In reply to ]
https://bugzilla.mindrot.org/show_bug.cgi?id=2948

--- Comment #11 from Damien Miller <djm@mindrot.org> ---
Comment on attachment 3344
--> https://bugzilla.mindrot.org/attachment.cgi?id=3344
sftp server copy-data extension

>+ /* Disallow reading & writing to the same handle */
>+ if (read_handle == write_handle || read_fd < 0 || write_fd < 0) {

Maybe mention here that this also ensures that both handles refer to
files rather than directories

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