From 1f04d1ed8865edd68d351f66452e50eb19345d7a Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 24 Oct 2025 14:21:30 +0200 Subject: [SERVER] iscsi: Restore proper padding of DataSegment This broke when sending ds payload was refactored to avoid copying the buffer into the PDU's buffer before sending. iscsi_connection_pdu_create took care of this before, but now that we send the source buffer directly, pad the packet manually after sending the buffer contents if required. --- src/server/iscsi.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/server') diff --git a/src/server/iscsi.c b/src/server/iscsi.c index 26c19eb..c1fc01f 100644 --- a/src/server/iscsi.c +++ b/src/server/iscsi.c @@ -448,6 +448,13 @@ static uint32_t iscsi_scsi_data_in_send(iscsi_connection *conn, iscsi_task *task // Set error return data_sn; } + if ( len % ISCSI_ALIGN_SIZE != 0 ) { + const size_t padding = ISCSI_ALIGN_SIZE - (len % ISCSI_ALIGN_SIZE); + if ( !sock_sendPadding( conn->client->sock, padding ) ) { + // Set error + return data_sn; + } + } } else { const off_t off = task->scsi_task.file_offset + pos; size_t padding = 0; -- cgit v1.2.3-55-g7522