[parted-devel] Possible bug on dvh label code

Otavio Salvador otavio at debian.org
Fri Apr 20 07:27:19 UTC 2007


Hello,

While Debarshi and I was working at unittest implementation, he found
a problem when using dvh labels. After some improvements on the
testing framework we were able to fail when we have raised
exceptions. Good!

Checking what was causing the exception I started to go deeply on code
and then found the reason but I'm not experienced at dvh labels to
know if it's right or not.

The bug is caused by the bellow code.
#v+
1  ped_disk_duplicate (const PedDisk* old_disk)
2  {
3  	PedDisk*	new_disk;
4  	PedPartition*	old_part;
5  
6  	PED_ASSERT (old_disk != NULL, return NULL);
7  	PED_ASSERT (!old_disk->update_mode, return NULL);
8  	PED_ASSERT (old_disk->type->ops->duplicate != NULL, return NULL);
9  	PED_ASSERT (old_disk->type->ops->partition_duplicate != NULL,
10 		    return NULL);
11 
12 	new_disk = old_disk->type->ops->duplicate (old_disk);
13 	if (!new_disk)
14 		goto error;
15 
16 	_disk_push_update_mode (new_disk);
17 	for (old_part = ped_disk_next_partition (old_disk, NULL); old_part;
18 	     old_part = ped_disk_next_partition (old_disk, old_part)) {
19 		if (ped_partition_is_active (old_part)) {
20 			if (!_add_duplicate_part (new_disk, old_part))
21 				goto error_destroy_new_disk;
22 		}
23 	}
24 	_disk_pop_update_mode (new_disk);
25 	return new_disk;
26 
27 error_destroy_new_disk:
28 	ped_disk_destroy (new_disk);
29 error:
30 	return NULL;
31 }
#v-

At line 16, the code changes new_disk->update_mode and then try to
walk through the partition table on the disk. Line 20 then fail and
make the code goes out without reverting the update_mode change. This
makes the exception to be raised later on ped_disk_destroy since it
checks this value and abort.

Does someone has any tip why this specific label is failing while the
others are not?

-- 
        O T A V I O    S A L V A D O R
---------------------------------------------
 E-mail: otavio at debian.org      UIN: 5906116
 GNU/Linux User: 239058     GPG ID: 49A5F855
 Home Page: http://otavio.ossystems.com.br
---------------------------------------------
"Microsoft sells you Windows ... Linux gives
 you the whole house."



More information about the parted-devel mailing list