Skip to content

Commit

Permalink
LDM: Fix reassembly of extended VBLKs.
Browse files Browse the repository at this point in the history
From: Ben Hutchings <ben@decadent.org.uk>

Extended VBLKs (those larger than the preset VBLK size) are divided
into fragments, each with its own VBLK header.  Our LDM implementation
generally assumes that each VBLK is contiguous in memory, so these
fragments must be assembled before further processing.

Currently the reassembly seems to be done quite wrongly - no VBLK
header is copied into the contiguous buffer, and the length of the
header is subtracted twice from each fragment.  Also the total
length of the reassembled VBLK is calculated incorrectly.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Anton Altaparmakov <anton@tuxera.com>
  • Loading branch information
AntonAltaparmakov committed Feb 24, 2012
1 parent 9b55624 commit 97387e3
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions block/partitions/ldm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ldm - Support for Windows Logical Disk Manager (Dynamic Disks)
*
* Copyright (C) 2001,2002 Richard Russon <ldm@flatcap.org>
* Copyright (c) 2001-2007 Anton Altaparmakov
* Copyright (c) 2001-2012 Anton Altaparmakov
* Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com>
*
* Documentation is available at http://www.linux-ntfs.org/doku.php?id=downloads
Expand Down Expand Up @@ -1341,20 +1341,17 @@ static bool ldm_frag_add (const u8 *data, int size, struct list_head *frags)
ldm_error("REC value (%d) exceeds NUM value (%d)", rec, f->num);
return false;
}

if (f->map & (1 << rec)) {
ldm_error ("Duplicate VBLK, part %d.", rec);
f->map &= 0x7F; /* Mark the group as broken */
return false;
}

f->map |= (1 << rec);

if (!rec)
memcpy(f->data, data, VBLK_SIZE_HEAD);
data += VBLK_SIZE_HEAD;
size -= VBLK_SIZE_HEAD;

memcpy (f->data+rec*(size-VBLK_SIZE_HEAD)+VBLK_SIZE_HEAD, data, size);

memcpy(f->data + VBLK_SIZE_HEAD + rec * size, data, size);
return true;
}

Expand Down

0 comments on commit 97387e3

Please sign in to comment.