sftpserver: Use SSH_STRING_FREE()

Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Andreas Schneider
2019-10-28 13:32:49 +01:00
parent 4cd084f13b
commit 449c0d66cc

View File

@@ -277,8 +277,8 @@ void sftp_client_message_free(sftp_client_message msg) {
SAFE_FREE(msg->filename);
SAFE_FREE(msg->submessage);
ssh_string_free(msg->data);
ssh_string_free(msg->handle);
SSH_STRING_FREE(msg->data);
SSH_STRING_FREE(msg->handle);
sftp_attributes_free(msg->attr);
ssh_buffer_free(msg->complete_message);
SAFE_FREE(msg->str_data);
@@ -309,11 +309,11 @@ int sftp_reply_name(sftp_client_message msg, const char *name,
buffer_add_attributes(out, attr) < 0 ||
sftp_packet_write(msg->sftp, SSH_FXP_NAME, out) < 0) {
ssh_buffer_free(out);
ssh_string_free(file);
SSH_STRING_FREE(file);
return -1;
}
ssh_buffer_free(out);
ssh_string_free(file);
SSH_STRING_FREE(file);
return 0;
}
@@ -368,27 +368,27 @@ int sftp_reply_names_add(sftp_client_message msg, const char *file,
if (msg->attrbuf == NULL) {
msg->attrbuf = ssh_buffer_new();
if (msg->attrbuf == NULL) {
ssh_string_free(name);
SSH_STRING_FREE(name);
return -1;
}
}
if (ssh_buffer_add_ssh_string(msg->attrbuf, name) < 0) {
ssh_string_free(name);
SSH_STRING_FREE(name);
return -1;
}
ssh_string_free(name);
SSH_STRING_FREE(name);
name = ssh_string_from_char(longname);
if (name == NULL) {
return -1;
}
if (ssh_buffer_add_ssh_string(msg->attrbuf,name) < 0 ||
buffer_add_attributes(msg->attrbuf,attr) < 0) {
ssh_string_free(name);
SSH_STRING_FREE(name);
return -1;
}
ssh_string_free(name);
SSH_STRING_FREE(name);
msg->attr_num++;
return 0;
@@ -444,12 +444,12 @@ int sftp_reply_status(sftp_client_message msg, uint32_t status,
ssh_buffer_add_u32(out, 0) < 0 || /* language string */
sftp_packet_write(msg->sftp, SSH_FXP_STATUS, out) < 0) {
ssh_buffer_free(out);
ssh_string_free(s);
SSH_STRING_FREE(s);
return -1;
}
ssh_buffer_free(out);
ssh_string_free(s);
SSH_STRING_FREE(s);
return 0;
}