All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>
To: device-mapper development <dm-devel@redhat.com>,
	Christophe Varoqui <christophe.varoqui@free.fr>
Subject: kpartx bug fixes for dos extended partition [3/4]
Date: Thu, 01 Dec 2005 15:22:33 -0500	[thread overview]
Message-ID: <438F5B89.5000903@ce.jp.nec.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]

Hi Christophe,

in the for loop in read_extended_partition,
'here' is updated if the next extended partition is found.

However, the 'here' value should be updated in the next while loop.
Otherwise it's possible that following partition table
entry refers updated value and generate wrong mapping.

I'm not sure if there is any partitioning tool which can generate
such table. But it's safer to fix this.

Thanks,
Nick

[-- Attachment #2: 03-kpartx-fix-cursor-update.patch --]
[-- Type: text/x-patch, Size: 1298 bytes --]

If the 1st slot of extended partition contains a pointer to
the next extended partition and the 2nd is normal logical partition,
incorrect mapping will be generated for the 2nd partition.

Usually, 2 slots of extended partition table is used
and the 2nd slot points to the next extended partition.
So this bug will not be hit in most cases.

--- multipath-tools.orig/kpartx/dos.c	2005-12-02 04:06:25.000000000 +0900
+++ multipath-tools/kpartx/dos.c	2005-12-02 01:33:41.000000000 +0900
@@ -20,15 +20,16 @@ read_extended_partition(int fd, struct p
 			struct slice *sp, int ns)
 {
 	struct partition p;
-	unsigned long start, here;
+	unsigned long start, here, next;
 	unsigned char *bp;
 	int loopct = 0;
 	int moretodo = 1;
 	int i, n=0;
 
-	here = start = le32_to_cpu(ep->start_sect);
+	next = start = le32_to_cpu(ep->start_sect);
 
 	while (moretodo) {
+		here = next;
 		moretodo = 0;
 		if (++loopct > 100)
 			return n;
@@ -43,8 +44,8 @@ read_extended_partition(int fd, struct p
 		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) {
-					here = start + le32_to_cpu(p.start_sect);
+				if (p.nr_sects && !moretodo) {
+					next = start + le32_to_cpu(p.start_sect);
 					moretodo = 1;
 				}
 				continue;

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



                 reply	other threads:[~2005-12-01 20:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=438F5B89.5000903@ce.jp.nec.com \
    --to=j-nomura@ce.jp.nec.com \
    --cc=christophe.varoqui@free.fr \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.