From c02428066964a0295fb7d83c3e1ad96d378a8b95 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Mon, 27 Mar 2023 21:50:16 +0200 Subject: [PATCH] sftp: Clarify the order of arguments for symlink Signed-off-by: Jakub Jelen Reviewed-by: Andreas Schneider Reviewed-by: Anderson Toshiyuki Sasaki --- src/sftp.c | 5 ++++- src/sftpserver.c | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/sftp.c b/src/sftp.c index ed353377..983d6831 100644 --- a/src/sftp.c +++ b/src/sftp.c @@ -2812,7 +2812,10 @@ int sftp_symlink(sftp_session sftp, const char *target, const char *dest) id = sftp_get_new_id(sftp); - /* TODO check for version number if they ever fix it. */ + /* The OpenSSH sftp server has order of the arguments reversed, see the + * section "4.1 sftp: Reversal of arguments to SSH_FXP_SYMLINK' in + * https://github.com/openssh/openssh-portable/blob/master/PROTOCOL + * for more information */ if (ssh_get_openssh_version(sftp->session)) { rc = ssh_buffer_pack(buffer, "dss", diff --git a/src/sftpserver.c b/src/sftpserver.c index 8d5ff665..57983f57 100644 --- a/src/sftpserver.c +++ b/src/sftpserver.c @@ -1462,6 +1462,11 @@ process_readlink(sftp_client_message client_msg) return ret; } +/* Note, that this function is using reversed order of the arguments than the + * OpenSSH sftp server as they have the arguments switched. See + * section "4.1 sftp: Reversal of arguments to SSH_FXP_SYMLINK' in + * https://github.com/openssh/openssh-portable/blob/master/PROTOCOL + * for more information */ static int process_symlink(sftp_client_message client_msg) {