diff --git a/src/sftpserver.c b/src/sftpserver.c index a92ae9ac..715198bb 100644 --- a/src/sftpserver.c +++ b/src/sftpserver.c @@ -833,7 +833,12 @@ int sftp_reply_version(sftp_client_message client_msg) "Sending version packet, ID %" PRIu32, client_msg->id); - version = sftp->client_version; + /* from draft-spaghetti-sshm-filexfer-00 Section 4: + * > The server responds with a SSH_FXP_VERSION packet, supplying the + * > lowest of its own and the client's version number. + */ + version = MIN(sftp->client_version, LIBSFTP_VERSION); + reply = ssh_buffer_new(); if (reply == NULL) { ssh_set_error_oom(session); @@ -842,7 +847,7 @@ int sftp_reply_version(sftp_client_message client_msg) rc = ssh_buffer_pack(reply, "dssssssss", - LIBSFTP_VERSION, + version, "posix-rename@openssh.com", "1", "hardlink@openssh.com", @@ -866,11 +871,7 @@ int sftp_reply_version(sftp_client_message client_msg) SSH_LOG(SSH_LOG_PROTOCOL, "Server version sent"); - if (version > LIBSFTP_VERSION) { - sftp->version = LIBSFTP_VERSION; - } else { - sftp->version = version; - } + sftp->version = version; return SSH_OK; }