1
1

sftp: Allocate a new buffer in sftp_packet_read() if needed

We will move the buffer to the message instead of duplicating the
memory.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
Andreas Schneider 2018-09-08 09:29:57 +02:00
родитель 97d2e1f4cb
Коммит be8302e2f3

Просмотреть файл

@ -339,11 +339,23 @@ sftp_packet sftp_packet_read(sftp_session sftp)
packet->sftp = sftp;
/*
* If the packet has a payload, then just reinit the buffer, otherwise
* allocate a new one.
*/
if (packet->payload != NULL) {
rc = ssh_buffer_reinit(packet->payload);
if (rc != 0) {
ssh_set_error_oom(sftp->session);
return NULL;
}
} else {
packet->payload = ssh_buffer_new();
if (packet->payload == NULL) {
ssh_set_error_oom(sftp->session);
return NULL;
}
}
nread = 0;
do {