From 2190bcfba4bb57e7184635b89c26a215a3fc2ea4 Mon Sep 17 00:00:00 2001 From: Seth Heeren Date: Tue, 5 Oct 2010 16:48:49 +0200 Subject: [PATCH] remove misuse of ustring in get_filesystem --- src/GParted_Core.cc | 26 +++++++++++++------------- 1 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 4f81fde..7c9fe27 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -1033,11 +1033,11 @@ GParted::FILESYSTEM GParted_Core::get_filesystem() { ped_device_open( lp_device ); ped_geometry_read( & lp_partition ->geom, buf, 0, 1 ) ; - strncpy(magic1, buf+0, 6) ; magic1[6] = '\0' ; //set and terminate string + memcpy(magic1, buf+0, 6) ; //set binary magic data ped_device_close( lp_device ); free( buf ) ; - if ( Glib::ustring( magic1 ) == "LUKS\xBA\xBE" ) + if ( 0 == memcmp( magic1 , "LUKS\xBA\xBE", 6 ) ) { temp = _( "Linux Unified Key Setup encryption is not yet supported." ) ; temp += "\n" ; @@ -1124,11 +1124,11 @@ GParted::FILESYSTEM GParted_Core::get_filesystem() , (65536 / lp_device ->sector_size) , 1 ) ; - strncpy(magic1, buf+0, 7) ; magic1[7] = '\0' ; //set and terminate string + memcpy(magic1, buf+0, 7) ; //set binary magic data ped_device_close( lp_device ); free( buf ) ; - if ( Glib::ustring( magic1 ) == "ReIsEr4" ) + if ( 0 == memcmp( magic1, "ReIsEr4", 7 ) ) return GParted::FS_REISER4 ; } @@ -1141,20 +1141,20 @@ GParted::FILESYSTEM GParted_Core::get_filesystem() if ( lp_device ->sector_size == 512 ) { ped_geometry_read( & lp_partition ->geom, buf, 1, 1 ) ; - strncpy(magic1, buf+ 0, 8) ; magic1[8] = '\0' ; //set and terminate string - strncpy(magic2, buf+24, 4) ; magic2[4] = '\0' ; //set and terminate string + memcpy(magic1, buf+ 0, 8) ; // set binary magic data + memcpy(magic2, buf+24, 4) ; // set binary magic data } else { ped_geometry_read( & lp_partition ->geom, buf, 0, 1 ) ; - strncpy(magic1, buf+ 0+512, 8) ; magic1[8] = '\0' ; //set and terminate string - strncpy(magic2, buf+24+512, 4) ; magic2[4] = '\0' ; //set and terminate string + memcpy(magic1, buf+ 0+512, 8) ; // set binary magic data + memcpy(magic2, buf+24+512, 4) ; // set binary magic data } ped_device_close( lp_device ); free( buf ) ; - if ( Glib::ustring( magic1 ) == "LABELONE" - && Glib::ustring( magic2 ) == "LVM2" ) + if ( 0 == memcmp( magic1, "LABELONE", 8 ) + && 0 == memcmp( magic2, "LVM2", 4 ) ) { temp = _( "Logical Volume Management is not yet supported." ) ; temp += "\n" ; @@ -1166,7 +1166,7 @@ GParted::FILESYSTEM GParted_Core::get_filesystem() //btrfs const Sector BTRFS_SUPER_INFO_SIZE = 4096 ; const Sector BTRFS_SUPER_INFO_OFFSET = (64 * 1024) ; - const Glib::ustring BTRFS_SIGNATURE = "_BHRfS_M" ; + const char* const BTRFS_SIGNATURE = "_BHRfS_M" ; char buf_btrfs[BTRFS_SUPER_INFO_SIZE] ; @@ -1176,10 +1176,10 @@ GParted::FILESYSTEM GParted_Core::get_filesystem() , (BTRFS_SUPER_INFO_OFFSET / lp_device ->sector_size) , (BTRFS_SUPER_INFO_SIZE / lp_device ->sector_size) ) ; - strncpy(magic1, buf_btrfs+64, BTRFS_SIGNATURE .size()) ; magic1[BTRFS_SIGNATURE .size()] = '\0' ; //set and terminate string + memcpy(magic1, buf_btrfs+64, strlen(BTRFS_SIGNATURE) ) ; //set binary magic data ped_device_close( lp_device ) ; - if ( magic1 == BTRFS_SIGNATURE ) + if ( 0 == memcmp( magic1, BTRFS_SIGNATURE, strlen(BTRFS_SIGNATURE) ) ) { temp = _( "BTRFS is not yet supported." ) ; temp += "\n" ; -- 1.7.0.4