sftp: Use ssh_buffer_pack() in sftp_canonicalize_path()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
родитель
8b19ef05f3
Коммит
1dd8466f66
30
src/sftp.c
30
src/sftp.c
@ -2989,7 +2989,6 @@ char *sftp_canonicalize_path(sftp_session sftp, const char *path)
|
|||||||
sftp_status_message status = NULL;
|
sftp_status_message status = NULL;
|
||||||
sftp_message msg = NULL;
|
sftp_message msg = NULL;
|
||||||
ssh_string name = NULL;
|
ssh_string name = NULL;
|
||||||
ssh_string pathstr;
|
|
||||||
ssh_buffer buffer;
|
ssh_buffer buffer;
|
||||||
char *cname;
|
char *cname;
|
||||||
uint32_t ignored;
|
uint32_t ignored;
|
||||||
@ -3009,38 +3008,23 @@ char *sftp_canonicalize_path(sftp_session sftp, const char *path)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pathstr = ssh_string_from_char(path);
|
id = sftp_get_new_id(sftp);
|
||||||
if (pathstr == NULL) {
|
|
||||||
ssh_set_error_oom(sftp->session);
|
|
||||||
ssh_buffer_free(buffer);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ssh_buffer_allocate_size(buffer,
|
rc = ssh_buffer_pack(buffer,
|
||||||
sizeof(uint32_t) * 2 +
|
"ds",
|
||||||
ssh_string_len(pathstr));
|
id,
|
||||||
|
path);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
ssh_set_error_oom(sftp->session);
|
ssh_set_error_oom(sftp->session);
|
||||||
ssh_buffer_free(buffer);
|
ssh_buffer_free(buffer);
|
||||||
ssh_string_free(pathstr);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
id = sftp_get_new_id(sftp);
|
rc = sftp_packet_write(sftp, SSH_FXP_REALPATH, buffer);
|
||||||
if (ssh_buffer_add_u32(buffer, htonl(id)) < 0 ||
|
|
||||||
ssh_buffer_add_ssh_string(buffer, pathstr) < 0) {
|
|
||||||
ssh_set_error_oom(sftp->session);
|
|
||||||
ssh_buffer_free(buffer);
|
ssh_buffer_free(buffer);
|
||||||
ssh_string_free(pathstr);
|
if (rc < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (sftp_packet_write(sftp, SSH_FXP_REALPATH, buffer) < 0) {
|
|
||||||
ssh_buffer_free(buffer);
|
|
||||||
ssh_string_free(pathstr);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
ssh_buffer_free(buffer);
|
|
||||||
ssh_string_free(pathstr);
|
|
||||||
|
|
||||||
while (msg == NULL) {
|
while (msg == NULL) {
|
||||||
if (sftp_read_and_dispatch(sftp) < 0) {
|
if (sftp_read_and_dispatch(sftp) < 0) {
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user