Resolve empty drive displayed as blank minor logic issue (#152)

The previous commit "Remove coding landmine in get_disk() (#152)" made
an empty drive without a disk label (partition table) display as
nothing, instead of the normal single unallocated partition with warning
"unrecognised disk label".

The previous commit said:
    3. The two remaining direct calls to get_disk() where the strict
       parameter is explicitly set to false, from set_device_from_disk()
       and detect_filesystem_in_encryption_mapping(), are when scanning.
       As the pass strict=false they don't allow the PedDevice deletion
       to occur if no recognised disk label is found.

This is true, but get_disk(..., strict=false) additionally returned true
even if there was no disk label.  And in set_device_from_disk() the
empty drive case is inside the if branch of the get_disk() call
returning true.

Simply fix this by calling get_disk(), ignoring the return value.

Closes #152 - GParted crashed when trying to probe an encrypted
              partition containing content that libparted doesn't
              recognise
This commit is contained in:
Mike Fleetwood 2021-04-10 17:08:07 +01:00 committed by Curtis Gedak
parent c4ef43aa5d
commit b3ff339ac7
1 changed files with 3 additions and 1 deletions

View File

@ -687,8 +687,10 @@ void GParted_Core::set_device_from_disk( Device & device, const Glib::ustring &
set_device_one_partition( device, lp_device, fstype, messages ); set_device_one_partition( device, lp_device, fstype, messages );
} }
// Partitioned drive // Partitioned drive
else if (get_disk(lp_device, lp_disk)) else
{ {
get_disk(lp_device, lp_disk);
// Partitioned drive (excluding "loop"), as recognised by libparted // Partitioned drive (excluding "loop"), as recognised by libparted
if ( lp_disk && lp_disk->type && lp_disk->type->name && if ( lp_disk && lp_disk->type && lp_disk->type->name &&
strcmp( lp_disk->type->name, "loop" ) != 0 ) strcmp( lp_disk->type->name, "loop" ) != 0 )