From 51df0d0512e105a8af11b92eec7fa6089b090f1e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 4 Sep 2022 14:36:18 -0700 Subject: [PATCH] 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 --- lib/scsi-lowlevel.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/scsi-lowlevel.c b/lib/scsi-lowlevel.c index 0161852..3349c9c 100644 --- a/lib/scsi-lowlevel.c +++ b/lib/scsi-lowlevel.c @@ -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)