1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2026-10-24 03:48:55 +03:00

sftpserver: Send right version based on the client one

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/849>
This commit is contained in:
Jakub Jelen
2026-06-30 14:24:46 +02:00
parent 782dfa6334
commit 6d2b270701

View File

@@ -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;
}