lib/scsi-lowlevel: Make the REPORT LUNS unmarshalling code more flexible

Instead of rejecting REPORT LUNS responses if the data buffer size exceeds
the LUN list size, truncate the data buffer.

Fixes: https://github.com/sahlberg/libiscsi/issues/385
This commit is contained in:
Bart Van Assche
2022-09-04 14:36:18 -07:00
parent 1017435ca9
commit 51df0d0512

View File

@@ -490,9 +490,8 @@ scsi_reportluns_datain_unmarshall(struct scsi_task *task)
}
list_size = task_get_uint32(task, 0) + 8;
if (list_size < task->datain.size) {
return NULL;
}
if (list_size > task->datain.size)
list_size = task->datain.size;
num_luns = list_size / 8 - 1;
list = scsi_malloc(task, offsetof(struct scsi_reportluns_list, luns)