From 812ba3b7175ef3e6c16409c20a40309c1c3f11f9 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Tue, 20 Jun 2023 15:09:32 +0200 Subject: [PATCH] sftp: Check return value of ssh_buffer_add_data CID 1513156 Thanks coverity Signed-off-by: Jakub Jelen Reviewed-by: Sahana Prasad --- src/sftp.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/sftp.c b/src/sftp.c index f598393c..d95af819 100644 --- a/src/sftp.c +++ b/src/sftp.c @@ -372,7 +372,7 @@ sftp_decode_channel_data_to_packet(sftp_session sftp, void *data, uint32_t len) int nread; int payload_len; unsigned int data_offset; - int to_read; + int to_read, rc; if (packet->sftp == NULL) { packet->sftp = sftp; @@ -393,9 +393,12 @@ sftp_decode_channel_data_to_packet(sftp_session sftp, void *data, uint32_t len) } to_read = payload_len - sizeof(uint8_t); - ssh_buffer_add_data(packet->payload, - (void*)((uint8_t *)data + data_offset), - to_read); + rc = ssh_buffer_add_data(packet->payload, + (void*)((uint8_t *)data + data_offset), + to_read); + if (rc != 0) { + return SSH_ERROR; + } nread = ssh_buffer_get_len(packet->payload); /* We should check if we copied the whole data */