From b662e3a2dcaf144471e0558681f4b78dac013f30 Mon Sep 17 00:00:00 2001 From: Bertrik Sikken Date: Sun, 16 Jun 2013 11:05:05 +0200 Subject: [PATCH] Fix response length calculation for SCSI_REPORT_LUNS Change-Id: I1167851bae20d9275eb2f441ce9dc73c8b2f09b1 Reviewed-on: http://gerrit.rockbox.org/488 Reviewed-by: Frank Gevaerts Reviewed-by: Bertrik Sikken Tested-by: Bertrik Sikken --- firmware/usbstack/usb_storage.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index c51b0faa4c..b898978776 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c @@ -816,7 +816,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) case SCSI_REPORT_LUNS: { logf("scsi report luns %d",lun); - int allocation_length=0; + unsigned int allocation_length=0; int i; unsigned int response_length = 8+8*storage_num_drives(); allocation_length|=(cbw->command_block[6]<<24); @@ -834,6 +834,7 @@ static void handle_scsi(struct command_block_wrapper* cbw) #endif tb.lun_data->luns[i][1]=0; } + length = MIN(length, allocation_length); send_command_result(tb.lun_data, MIN(response_length, length)); break;