[gparted] Replace 32-bit member variable "index" with wider local variables (#764658)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Replace 32-bit member variable "index" with wider local variables (#764658)
- Date: Thu, 7 Apr 2016 15:59:33 +0000 (UTC)
commit a681f9f63733d9834179a02ce65438c5b6cb4b96
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Wed Apr 6 07:22:01 2016 +0100
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
include/FileSystem.h | 1 -
src/ext2.cc | 2 +-
src/fat16.cc | 2 +-
src/jfs.cc | 2 +-
src/ntfs.cc | 2 +-
src/reiser4.cc | 2 +-
src/reiserfs.cc | 2 +-
src/xfs.cc | 2 +-
8 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/include/FileSystem.h b/include/FileSystem.h
index c5693bd..4b16735 100644
--- a/include/FileSystem.h
+++ b/include/FileSystem.h
@@ -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,
diff --git a/src/ext2.cc b/src/ext2.cc
index bcd0530..e3736d0 100644
--- a/src/ext2.cc
+++ b/src/ext2.cc
@@ -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 ;
diff --git a/src/fat16.cc b/src/fat16.cc
index e85042f..fe38898 100644
--- a/src/fat16.cc
+++ b/src/fat16.cc
@@ -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 ;
diff --git a/src/jfs.cc b/src/jfs.cc
index 866bce0..210406b 100644
--- a/src/jfs.cc
+++ b/src/jfs.cc
@@ -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 ;
diff --git a/src/ntfs.cc b/src/ntfs.cc
index 50716be..90031cb 100644
--- a/src/ntfs.cc
+++ b/src/ntfs.cc
@@ -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 ;
diff --git a/src/reiser4.cc b/src/reiser4.cc
index 92d4911..b588cc4 100644
--- a/src/reiser4.cc
+++ b/src/reiser4.cc
@@ -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 ;
diff --git a/src/reiserfs.cc b/src/reiserfs.cc
index 710f3f9..ca493cf 100644
--- a/src/reiserfs.cc
+++ b/src/reiserfs.cc
@@ -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 ;
diff --git a/src/xfs.cc b/src/xfs.cc
index 1cc36a6..d43cf89 100644
--- a/src/xfs.cc
+++ b/src/xfs.cc
@@ -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 ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]