1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-30 13:01:23 +03:00

sftp: Use ssh_buffer_pack() in sftp_fstat()

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Andreas Schneider
2018-08-31 19:40:29 +02:00
parent f3ffd8aa41
commit e601dbd8e3

View File

@@ -3157,27 +3157,23 @@ sftp_attributes sftp_fstat(sftp_file file)
return NULL; return NULL;
} }
rc = ssh_buffer_allocate_size(buffer, id = sftp_get_new_id(file->sftp);
sizeof(uint32_t) * 2 +
ssh_string_len(file->handle)); rc = ssh_buffer_pack(buffer,
if (rc < 0) { "dS",
id,
file->handle);
if (rc != SSH_OK) {
ssh_set_error_oom(file->sftp->session); ssh_set_error_oom(file->sftp->session);
ssh_buffer_free(buffer); ssh_buffer_free(buffer);
return NULL; return NULL;
} }
id = sftp_get_new_id(file->sftp); rc = sftp_packet_write(file->sftp, SSH_FXP_FSTAT, buffer);
if (ssh_buffer_add_u32(buffer, htonl(id)) < 0 ||
ssh_buffer_add_ssh_string(buffer, file->handle) < 0) {
ssh_set_error_oom(file->sftp->session);
ssh_buffer_free(buffer);
return NULL;
}
if (sftp_packet_write(file->sftp, SSH_FXP_FSTAT, buffer) < 0) {
ssh_buffer_free(buffer);
return NULL;
}
ssh_buffer_free(buffer); ssh_buffer_free(buffer);
if (rc < 0) {
return NULL;
}
while (msg == NULL) { while (msg == NULL) {
if (sftp_read_and_dispatch(file->sftp) < 0) { if (sftp_read_and_dispatch(file->sftp) < 0) {