From 18941e24d3cb0b97a6d7cf52800f8f506f6a9ba8 Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Sat, 29 Dec 2012 10:00:55 +0000 Subject: [PATCH] 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 file changed, 3 insertions(+) diff --git a/src/reiser4.cc b/src/reiser4.cc index 08824688..44bbb0c5 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 != "" ) partition .set_label( label ) ; else