From patchwork Tue Feb 14 04:06:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 9571191 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D76C16045F for ; Tue, 14 Feb 2017 04:08:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8D4F27D5E for ; Tue, 14 Feb 2017 04:08:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDBC827FA6; Tue, 14 Feb 2017 04:08:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7A62327D5E for ; Tue, 14 Feb 2017 04:08:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1E475T1040361; Mon, 13 Feb 2017 23:07:05 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1E46u3w006625 for ; Mon, 13 Feb 2017 23:06:56 -0500 Received: from redhat.com (octiron.msp.redhat.com [10.15.80.209]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id v1E46tot013413; Mon, 13 Feb 2017 23:06:55 -0500 Received: by redhat.com (sSMTP sendmail emulation); Mon, 13 Feb 2017 22:06:55 -0600 From: "Benjamin Marzinski" To: device-mapper development Date: Mon, 13 Feb 2017 22:06:47 -0600 Message-Id: <1487045213-15776-2-git-send-email-bmarzins@redhat.com> In-Reply-To: <1487045213-15776-1-git-send-email-bmarzins@redhat.com> References: <1487045213-15776-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-loop: dm-devel@redhat.com Cc: Cedric Buissart Subject: [dm-devel] [PATCH v2 1/7] kpartx: don't keep creating recursive partitions X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Virus-Scanned: ClamAV using ClamSMTP If the dos partition table is corrupted, kpartx can just keep creating the same partitions until it runs out of partition numbers. This check catches the recursion. Signed-off-by: Cedric Buissart Signed-off-by: Benjamin Marzinski --- kpartx/dos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpartx/dos.c b/kpartx/dos.c index 64b27b6..4985152 100644 --- a/kpartx/dos.c +++ b/kpartx/dos.c @@ -46,7 +46,7 @@ read_extended_partition(int fd, struct partition *ep, int en, for (i=0; i<2; i++) { memcpy(&p, bp + 0x1be + i * sizeof (p), sizeof (p)); if (is_extended(p.sys_type)) { - if (p.nr_sects && !moretodo) { + if (p.start_sect && p.nr_sects && !moretodo) { next = start + sector_size_mul * le32_to_cpu(p.start_sect); moretodo = 1; }