[gparted] Avoid reading trailing junk for a reiser4 label (#689318)



commit 18941e24d3cb0b97a6d7cf52800f8f506f6a9ba8
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sat Dec 29 10:00:55 2012 +0000

    Avoid reading trailing junk for a reiser4 label (#689318)
    
    For a reiser4 file system with exactly the maximum size 16 character
    label, debugfs.reiser4 may include junk at the end of the label it
    prints.  (It reads the label into a 16 character array and prints it as
    a string, but there isn't a nul terminating character).
    
        # mkfs.reiser4 --yes --label abcdefghij123456 /dev/sda13
        # debugfs.reiser4 /dev/sda13 2> /dev/null | grep label:
        label:          abcdefghij123456!
    
    Trim the read label to at most 16 characters.
    
    Bug #689318 - filesystem type specific support for partition name
                  maximum length

 src/reiser4.cc |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/src/reiser4.cc b/src/reiser4.cc
index 0882468..44bbb0c 100644
--- a/src/reiser4.cc
+++ b/src/reiser4.cc
@@ -97,6 +97,9 @@ void reiser4::read_label( Partition & partition )
 	if ( ! Utils::execute_command( "debugfs.reiser4 " + partition .get_path(), output, error, true ) )
 	{
 		Glib::ustring label = Utils::regexp_label( output, "^label:[[:blank:]]*(.*)$" ) ;
+		//Avoid reading any trailing junk after the label
+		if ( label .length() > 16 )
+			label .resize( 16 ) ;
 		if ( label != "<none>" )
 			partition .set_label( label ) ;
 		else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]