Correctly const and assert detect_filesystem() parameters (#152)
As discussed in the previous commit "Don't crash probing libparted unrecognised encrypted file system (#152)", detect_filesystem() accepted a NULL lp_device pointer and dereferenced it leading to the crash. Document the requirement for lp_device parameter to be non-NULL via an assert and also correctly const the parameters. This forces needing to const the lp_partition parameter to get_partition_path() too. Also assert it's non-NULL requirement. Closes #152 - GParted crashed when trying to probe an encrypted partition containing content that libparted doesn't recognise
This commit is contained in:
parent
09df074a92
commit
8280f3eedc
|
@ -82,7 +82,7 @@ public:
|
|||
private:
|
||||
//detectionstuff..
|
||||
void set_thread_status_message( Glib::ustring msg ) ;
|
||||
static Glib::ustring get_partition_path( PedPartition * lp_partition );
|
||||
static Glib::ustring get_partition_path(const PedPartition *lp_partition);
|
||||
void set_device_from_disk( Device & device, const Glib::ustring & device_path );
|
||||
void set_device_serial_number( Device & device );
|
||||
void set_device_partitions( Device & device, PedDevice* lp_device, PedDisk* lp_disk ) ;
|
||||
|
@ -93,8 +93,8 @@ private:
|
|||
static FSType detect_filesystem_in_encryption_mapping(const Glib::ustring& path,
|
||||
std::vector<Glib::ustring>& messages);
|
||||
static FSType detect_filesystem_internal(const Glib::ustring& path, Byte_Value sector_size);
|
||||
static FSType detect_filesystem( PedDevice * lp_device, PedPartition * lp_partition,
|
||||
std::vector<Glib::ustring> & messages );
|
||||
static FSType detect_filesystem(const PedDevice *lp_device, const PedPartition *lp_partition,
|
||||
std::vector<Glib::ustring> &messages);
|
||||
void read_label( Partition & partition ) ;
|
||||
void read_uuid( Partition & partition ) ;
|
||||
void set_mountpoints( Partition & partition );
|
||||
|
|
|
@ -618,8 +618,10 @@ std::map<Glib::ustring, bool> GParted_Core::get_available_flags( const Partition
|
|||
|
||||
//private functions...
|
||||
|
||||
Glib::ustring GParted_Core::get_partition_path( PedPartition * lp_partition )
|
||||
Glib::ustring GParted_Core::get_partition_path(const PedPartition *lp_partition)
|
||||
{
|
||||
g_assert(lp_partition != NULL); // Bug: Not initialised by suitable ped_disk_*partition*() call
|
||||
|
||||
char * lp_path; //we have to free the result of ped_partition_get_path()
|
||||
Glib::ustring partition_path = "Partition path not found";
|
||||
|
||||
|
@ -1218,9 +1220,12 @@ FSType GParted_Core::detect_filesystem_internal(const Glib::ustring& path, Byte_
|
|||
return fstype;
|
||||
}
|
||||
|
||||
FSType GParted_Core::detect_filesystem( PedDevice * lp_device, PedPartition * lp_partition,
|
||||
std::vector<Glib::ustring> & messages )
|
||||
|
||||
FSType GParted_Core::detect_filesystem(const PedDevice *lp_device, const PedPartition *lp_partition,
|
||||
std::vector<Glib::ustring> &messages)
|
||||
{
|
||||
g_assert(lp_device != NULL); // Bug: Not initialised by call to ped_device_get() or ped_device_get_next()
|
||||
|
||||
Glib::ustring fsname = "";
|
||||
Glib::ustring path;
|
||||
DMRaid dmraid;
|
||||
|
|
Loading…
Reference in New Issue