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
This commit is contained in:
parent
aed5ef2b6f
commit
18941e24d3
|
@ -97,6 +97,9 @@ void reiser4::read_label( Partition & partition )
|
||||||
if ( ! Utils::execute_command( "debugfs.reiser4 " + partition .get_path(), output, error, true ) )
|
if ( ! Utils::execute_command( "debugfs.reiser4 " + partition .get_path(), output, error, true ) )
|
||||||
{
|
{
|
||||||
Glib::ustring label = Utils::regexp_label( output, "^label:[[:blank:]]*(.*)$" ) ;
|
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>" )
|
if ( label != "<none>" )
|
||||||
partition .set_label( label ) ;
|
partition .set_label( label ) ;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue