[PATCH] gpt_write: fix a write-uninitialized error

Jim Meyering meyering at redhat.com
Fri May 30 19:10:06 UTC 2008


* libparted/labels/gpt.c (gpt_partition_new):
  ==32570== Syscall param write(buf) points to uninitialised byte(s)
  ==32570==    at 0x36CF8D6540: __write_nocancel (in /lib64/libc-2.8.so)
  ==32570==    by 0x443D29: linux_write (linux.c:1642)
  ==32570==    by 0x414E4E: ped_device_write (device.c:370)
  ==32570==    by 0x4404CE: gpt_write (gpt.c:1091)
  ==32570==    by 0x418F16: ped_disk_commit_to_dev (disk.c:486)
  ==32570==    by 0x418F5C: ped_disk_commit (disk.c:509)
  ==32570==    by 0x40BAD6: do_mkpartfs (parted.c:981)
  ==32570==    by 0x40A035: command_run (command.c:139)
  ==32570==    by 0x412150: non_interactive_mode (ui.c:1540)
  ==32570==    by 0x40EE83: main (parted.c:2487)
  ==32570==  Address 0x501b63a is 58 bytes inside a block of size 16,384 alloc'd
  ==32570==    at 0x4A04FC0: memalign (vg_replace_malloc.c:460)
  ==32570==    by 0x4A0507A: posix_memalign (vg_replace_malloc.c:569)
  ==32570==    by 0x443CED: linux_write (linux.c:1637)
  ==32570==    by 0x414E4E: ped_device_write (device.c:370)
  ==32570==    by 0x4404CE: gpt_write (gpt.c:1091)
  ==32570==    by 0x418F16: ped_disk_commit_to_dev (disk.c:486)
  ==32570==    by 0x418F5C: ped_disk_commit (disk.c:509)
  ==32570==    by 0x40BAD6: do_mkpartfs (parted.c:981)
  ==32570==    by 0x40A035: command_run (command.c:139)
  ==32570==    by 0x412150: non_interactive_mode (ui.c:1540)
  ==32570==    by 0x40EE83: main (parted.c:2487)

  reproduce with this:
  dev=f
  dd if=/dev/null of=$dev bs=1 seek=30M 2>/dev/null
  ./parted -s $dev mklabel gpt
  valgrind ./parted -s $dev mkpartfs primary ext2 0 16795000B
---
 libparted/labels/gpt.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index d09d751..1e0becd 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1154,7 +1154,7 @@ gpt_partition_new (const PedDisk* disk,
         gpt_part_data->msftres = 0;
 	uuid_generate ((unsigned char*) &gpt_part_data->uuid);
 	swap_uuid_and_efi_guid((unsigned char*)(&gpt_part_data->uuid));
-	strcpy (gpt_part_data->name, "");
+	memset (gpt_part_data->name, 0, sizeof gpt_part_data->name);
 	return part;

 error_free_part:
-- 
1.5.6.rc0.30.g7c3f3




More information about the parted-devel mailing list