#208184 The disk label can be corrupted

#208184#5
Date:
2003-09-01 10:52:50 UTC
From:
To:
Hi!

Attached you will find a compressed disk image bug.disk.  Here is how
you can corrupt its label:

$ parted bug.disk
Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This program is free software, covered by the GNU General Public License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Using /tmp/bug/bug.disk
(parted) p
Disk geometry for /tmp/bug/bug.disk: 0.000-14.636 megabytes
Disk label type: msdos
Minor    Start       End     Type      Filesystem  Flags
1          0.016      0.875  primary
3          0.875      1.000  extended
8          0.876      0.890  logical
6          0.891      0.937  logical
7          0.938      0.938  logical
5          0.938      0.953  logical
2          1.000     14.625  primary
(parted) mkpart logical linux-swap 0.954 0.999
Error: Can't have overlapping partitions
(parted) q

This bug is in libparted rather than in parted as you can see from
this small C program:

#include <parted/parted.h>

int main() {
        PedDevice *dev;
        PedDisk *disk;
        PedPartition *part;
        dev = ped_device_get("bug.disk");
        disk = ped_disk_new(dev);
        part = ped_partition_new(disk,
                                 PED_PARTITION_LOGICAL,
                                 ped_file_system_type_get("linux-swap"),
                                 1952, 2047);
        ped_disk_print(disk);
        if (!ped_disk_check(disk)) return;
        ped_disk_add_partition(disk, part, ped_constraint_any(dev));
        ped_disk_print(disk);
        ped_disk_commit(disk);
}


Anton Zinoviev

#208184#8
Date:
2003-09-01 14:08:21 UTC
From:
To:
Hrm - I can verify this one! wierd ...