Mike Hwang <[email protected]> wrote:
> I found a bug.
>
> In libparted/arch/linux.c:333
>
>
> next = dm_get_next_target(dmt, NULL, &start, &length,
> &target_type, ¶ms);
>
> 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:
>From e94d23fb1e226beaf3ce02fee9c2f69eb5636674 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Fri, 13 Feb 2009 12:08:13 +0100
Subject: [PATCH] don't segfault on a device-mapper device with no target
* libparted/arch/linux.c (_dm_maptype): Don't dereference NULL
for a device-mapper device with no target. Use the string
"NO-TARGET" instead. Reported by Mike Hwang in
http://thread.gmane.org/gmane.comp.gnu.parted.devel/2432
---
libparted/arch/linux.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index da812d5..4a8c9e7 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -348,7 +348,7 @@ _dm_maptype (PedDevice *dev)
next = dm_get_next_target(dmt, NULL, &start, &length,
&target_type, ¶ms);
- arch_specific->dmtype = strdup(target_type);
+ arch_specific->dmtype = strdup(target_type ? target_type :
"NO-TARGET");
if (arch_specific->dmtype == NULL)
goto bad;
r = 0;
--
1.6.2.rc0.226.gf08f
_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel