From patchwork Wed Feb 3 10:13:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffy Chen X-Patchwork-Id: 577808 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 455BD140328 for ; Wed, 3 Feb 2016 21:11:46 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 92AE6A7552; Wed, 3 Feb 2016 11:11:43 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VEmtM3-3cEbz; Wed, 3 Feb 2016 11:11:43 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 07F26A753A; Wed, 3 Feb 2016 11:11:43 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 11744A753A for ; Wed, 3 Feb 2016 11:11:37 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ygDybJQ1bw5Y for ; Wed, 3 Feb 2016 11:11:36 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.99.138]) by theia.denx.de (Postfix) with ESMTPS id 69D52A749F for ; Wed, 3 Feb 2016 11:11:31 +0100 (CET) Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.172]) by regular1.263xmail.com (Postfix) with SMTP id 8E6B7506A; Wed, 3 Feb 2016 18:11:24 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 8337840E; Wed, 3 Feb 2016 18:11:21 +0800 (CST) X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: u-boot@lists.denx.de X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: <6d207f3b8c86efb297860178cd308548> X-ATTACHMENT-NUM: 0 X-SENDER: cjf@rock-chips.com X-DNS-TYPE: 0 Received: from localhost (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 1806133MK0O; Wed, 03 Feb 2016 18:11:22 +0800 (CST) From: Jeffy Chen To: u-boot@lists.denx.de Date: Wed, 3 Feb 2016 18:13:55 +0800 Message-Id: <1454494435-12793-1-git-send-email-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.1.4 Cc: trini@konsulko.com, Jeffy Chen , ccross@android.com Subject: [U-Boot] [PATCH] fastboot: sparse: fix sparse blocks calculation X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" It may overflow in sparse_block_size_to_storage, use uint64_t instead in the calculation. Signed-off-by: Jeffy Chen --- common/image-sparse.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/image-sparse.c b/common/image-sparse.c index 542a8c4..0c07976 100644 --- a/common/image-sparse.c +++ b/common/image-sparse.c @@ -62,7 +62,8 @@ static unsigned int sparse_block_size_to_storage(unsigned int size, sparse_storage_t *storage, sparse_header_t *sparse) { - return size * sparse->blk_sz / storage->block_sz; + return (unsigned int)lldiv((uint64_t)size * sparse->blk_sz, + storage->block_sz); } static bool sparse_chunk_has_buffer(chunk_header_t *chunk)