[parted-devel] parted crashed on reading DM device without target

Jim Meyering jim at meyering.net
Fri Feb 13 11:14:24 UTC 2009

Mike Hwang <Mike.Hwang at iqstor.com.cn> wrote:
> I found a bug.
> In libparted/arch/linux.c:333
>         next = dm_get_next_target(dmt, NULL, &start, &length,
>                                   &target_type, &params);
>         arch_specific->dmtype = strdup(target_type);
> Once we have DM name with empty target, 'target_type' will be NULL and
> the program will crash at strdup.
> FYI: DM device with empty target could be created with command 'dmsetup
> create'. Once the command prompt for target input, type ctrl-D

Hi Mike,

Thank you for the fine bug report.

At first I was unable to reproduce it, because I had not
specifically configured with --enable-device-mapper.

  [ This is yet another reason to make that the default,
    when the prerequisites are available.. ]

My failed attempt to reproduce went like this:

  # :|dmsetup create no-target
  # parted/parted -m -s /dev/mapper/no-target p
  Warning: Unable to determine geometry of file/device /dev/mapper/no-target.\
  You should not use Parted unless you REALLY know what you're doing!
  Error: /dev/mapper/no-target: unrecognised disk label

Once I rebuilt with --enable-device-mapper, I hit the failure:

  # parted/parted -m -s /dev/mapper/no-target p
  zsh: segmentation fault  sudo parted/parted -m -s /dev/mapper/no-target p

And repeating after the fix, I get the expected error, as before.

Here's how I've fixed it:

More information about the parted-devel mailing list