Subject: bug#35715: parted crashed when extended partition doesn't start on physical sector boundary

From: Jens Schmidt <[email-masked]>
Date: Mon, 13 May 2019 16:23:15 +0200

Hello developer team.

parted crashed when extended partition doesn't
start on physical sector boundary.

On my older laptop's HDD the extended partition isn't aligned to
4096 bytes boundary but to 512 bytes. This is not really a problem
because extended partition has only one sector in size and the speed
reduction due to unaligned partition is not likely to be noticeable.

parted never should crash when reading such a partition table!

Please fix ASAP because this bug is at least five years old and has
many entries in Google search.

Output of: 'parted /dev/sda unit co print unit s print'
------
Backtrace has 14 calls on stack:
  14: /lib/i386-linux-gnu/libparted.so.2(ped_assert+0x51) [0xb76cd471]
  13: /lib/i386-linux-gnu/libparted.so.2(+0x2320a) [0xb76e820a]
  12: /lib/i386-linux-gnu/libparted.so.2(+0xdaf8) [0xb76d2af8]
  11: /lib/i386-linux-gnu/libparted.so.2(ped_disk_add_partition+0x2ac) [0xb76d34fc]
  10: /lib/i386-linux-gnu/libparted.so.2(+0x22af7) [0xb76e7af7]
  9: /lib/i386-linux-gnu/libparted.so.2(+0x22bee) [0xb76e7bee]
  8: /lib/i386-linux-gnu/libparted.so.2(+0x22b30) [0xb76e7b30]
  7: /lib/i386-linux-gnu/libparted.so.2(+0x23e60) [0xb76e8e60]
  6: /lib/i386-linux-gnu/libparted.so.2(ped_disk_new+0x5b) [0xb76d30cb]
  5: parted(+0x682b) [0x8007282b]
  4: parted(non_interactive_mode+0x8f) [0x800780bf]
  3: parted(main+0x10e3) [0x80070713]
  2: /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf6) [0xb74b8286]
  1: parted(+0x489c) [0x8007089c]

[..]

Assertion (metadata_length > 0) at ../../../libparted/labels/dos.c:2313
in function add_logical_part_metadata() failed.
------

Output of: 'fdisk -l /dev/sda'
------------
Disk /dev/sda: 931,5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xbfd1a1b9

Device     Boot      Start        End    Sectors   Size Id Type
/dev/sda1             2048     206847     204800   100M 83 Linux
/dev/sda2  *        206848  335636479  335429632   160G  7 HPFS/NTFS/exFAT
/dev/sda3        335636480  335699967      63488    31M ef EFI (FAT-12/16/32)
/dev/sda4        335703422 1953524292 1617820871 771,4G  5 Extended
/dev/sda5        335706112  339899775    4193664     2G 82 Linux swap / Solaris
/dev/sda6        339899776  457083369  117183594  55,9G 83 Linux
/dev/sda7        457085424  574269935  117184512  55,9G 83 Linux
/dev/sda8        574271984 1530140671  955868688 455,8G 83 Linux
/dev/sda9       1530142720 1851125759  320983040 153,1G 83 Linux
/dev/sda10      1851127808 1953319492  102191685  48,7G 83 Linux
/dev/sda11      1953323008 1953524292     201285  98,3M 83 Linux
------------

Best regards
Jens