Replace 32-bit member variable "index" with wider local variables (#764658)
The previous commit (Fix crash reading NTFS usage when there is no /dev/PTN entry) identified that the FileSystem member variable "index" is too small on 64-bit machines. Also this member variable stores no FileSystem class information and was being used as a local variable. Replace with local variables of the of the correct type, wide enough to store the npos not found value. Bug 764658 - GParted crashes when reading NTFS usage when there is no /dev/PTN entry
This commit is contained in:
parent
366152e449
commit
a681f9f637
|
@ -102,7 +102,6 @@ protected:
|
|||
Glib::ustring output, error ;
|
||||
Sector T, N, S ; //File system [T]otal num of blocks, [N]um of free (or used) blocks, block [S]ize
|
||||
int exit_status ;
|
||||
unsigned int index ;
|
||||
|
||||
private:
|
||||
int execute_command_internal( const Glib::ustring & command, OperationDetail & operationdetail,
|
||||
|
|
|
@ -128,7 +128,7 @@ void ext2::set_used_sectors( Partition & partition )
|
|||
// unmounted.
|
||||
if ( ! Utils::execute_command( dump_cmd + " -h " + partition .get_path(), output, error, true ) )
|
||||
{
|
||||
index = output .find( "Block count:" ) ;
|
||||
Glib::ustring::size_type index = output.find( "Block count:" );
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output.substr( index ) .c_str(), "Block count: %Ld", &T ) != 1 )
|
||||
T = -1 ;
|
||||
|
|
|
@ -136,7 +136,7 @@ void fat16::set_used_sectors( Partition & partition )
|
|||
if ( exit_status == 0 || exit_status == 1 )
|
||||
{
|
||||
//total file system size in logical sectors
|
||||
index = output .rfind( "\n", output .find( "sectors total" ) ) +1 ;
|
||||
Glib::ustring::size_type index = output.rfind( "\n", output.find( "sectors total" ) ) + 1;
|
||||
if ( index >= output .length() || sscanf( output .substr( index ) .c_str(), "%Ld", &T ) != 1 )
|
||||
T = -1 ;
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ void jfs::set_used_sectors( Partition & partition )
|
|||
if ( ! Utils::execute_command( "sh -c 'echo dm | jfs_debugfs " + partition.get_path() + "'", output, error, true ) )
|
||||
{
|
||||
//blocksize
|
||||
index = output .find( "Block Size:" ) ;
|
||||
Glib::ustring::size_type index = output.find( "Block Size:" );
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output .substr( index ) .c_str(), "Block Size: %Ld", &S ) != 1 )
|
||||
S = -1 ;
|
||||
|
|
|
@ -127,7 +127,7 @@ void ntfs::set_used_sectors( Partition & partition )
|
|||
"ntfsresize --info --force --no-progress-bar " + partition .get_path(), output, error, true ) ;
|
||||
if ( exit_status == 0 || exit_status == 1 )
|
||||
{
|
||||
index = output .find( "Current volume size:" ) ;
|
||||
Glib::ustring::size_type index = output.find( "Current volume size:" );
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output .substr( index ) .c_str(), "Current volume size: %Ld", &T ) != 1 )
|
||||
T = -1 ;
|
||||
|
|
|
@ -64,7 +64,7 @@ void reiser4::set_used_sectors( Partition & partition )
|
|||
{
|
||||
if ( ! Utils::execute_command( "debugfs.reiser4 " + partition .get_path(), output, error, true ) )
|
||||
{
|
||||
index = output .find( "\nblocks:" ) ;
|
||||
Glib::ustring::size_type index = output.find( "\nblocks:" );
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output.substr( index ) .c_str(), "\nblocks: %Ld", &T ) != 1 )
|
||||
T = -1 ;
|
||||
|
|
|
@ -81,7 +81,7 @@ void reiserfs::set_used_sectors( Partition & partition )
|
|||
{
|
||||
if ( ! Utils::execute_command( "debugreiserfs " + partition .get_path(), output, error, true ) )
|
||||
{
|
||||
index = output .find( "Count of blocks on the device:" ) ;
|
||||
Glib::ustring::size_type index = output.find( "Count of blocks on the device:" );
|
||||
if ( index >= output .length() ||
|
||||
sscanf( output .substr( index ) .c_str(), "Count of blocks on the device: %Ld", &T ) != 1 )
|
||||
T = -1 ;
|
||||
|
|
|
@ -99,7 +99,7 @@ void xfs::set_used_sectors( Partition & partition )
|
|||
S = -1 ;
|
||||
|
||||
//filesystem blocks
|
||||
index = output .find( "\ndblocks" ) ;
|
||||
Glib::ustring::size_type index = output.find( "\ndblocks" );
|
||||
if ( index > output .length() ||
|
||||
sscanf( output .substr( index ) .c_str(), "\ndblocks = %Ld", &T ) != 1 )
|
||||
T = -1 ;
|
||||
|
|
Loading…
Reference in New Issue