From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHhlG-00077L-0h for qemu-devel@nongnu.org; Fri, 08 Jan 2016 19:52:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHhlE-0005jX-4e for qemu-devel@nongnu.org; Fri, 08 Jan 2016 19:52:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39024) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHhlD-0005jT-Vg for qemu-devel@nongnu.org; Fri, 08 Jan 2016 19:52:04 -0500 From: John Snow Date: Fri, 8 Jan 2016 19:51:48 -0500 Message-Id: <1452300718-10660-2-git-send-email-jsnow@redhat.com> In-Reply-To: <1452300718-10660-1-git-send-email-jsnow@redhat.com> References: <1452300718-10660-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PULL 01/11] macio: fix overflow in lba to offset conversion for ATAPI devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Mark Cave-Ayland , jsnow@redhat.com From: Mark Cave-Ayland As the IDEState lba field is an int32_t, make sure we cast to int64_t before shifting to calculate the offset. Otherwise we end up with an overflow when trying to access sectors beyond 2GB as can occur when using DVD images. [Maintainer edit: fixed extraneous parentheses. --js] Signed-off-by: Mark Cave-Ayland Reviewed-by: John Snow Message-id: 1451928613-29476-1-git-send-email-mark.cave-ayland@ilande.co.uk Signed-off-by: John Snow --- hw/ide/macio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ide/macio.c b/hw/ide/macio.c index 3ee962f..1678b2f 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -280,7 +280,7 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) } /* Calculate current offset */ - offset = (int64_t)(s->lba << 11) + s->io_buffer_index; + offset = ((int64_t)s->lba << 11) + s->io_buffer_index; pmac_dma_read(s->blk, offset, io->len, pmac_ide_atapi_transfer_cb, io); return; -- 2.4.3