mirror of
https://gitlab.gnome.org/GNOME/gparted
synced 2024-08-27 03:30:17 +00:00
Pad fat16/32 file system labels with spaces (#700228)
Mlabel sometimes writes uninitialised memory at the end of the label. This causes mlabel, and therefore GParted, to display extra junk at the end of the label. Depending on the bytes written GParted may also show the following error on stdout: (gpartedbin:18116): glibmm-CRITICAL **: unhandled exception (type Glib::Error) in signal handler: domain: g_convert_error code : 1 what : Invalid byte sequence in conversion input This is caused by a bug in mlabel, believed fixed in mtools 4.0.14. Effects at least Fedora 14, RHEL/CentOS 6.x and Debian 6. (Use label "1234567890" on Debian 6 to reproduce). Reproduction steps: # mkdosfs -F16 /dev/sda7 mkdosfs 3.0.9 (31 Jan 2010) # export MTOOLS_SKIP_CHECK=1 # mlabel ::123456 -i /dev/sda7 # mlabel -s :: -i /dev/sda7 Volume label is 123456~1t It is not possible to detect which characters are junk so they can't be trimmed. Instead just space pad labels so that at least newly written labels aren't effected. (Fat labels are space padded on the disk by definition anyway). Bug #700228 - FAT16/32 labels are sometimes shown corrupted
This commit is contained in:
parent
519af1a7c0
commit
7ede0ca3cc
|
@ -42,6 +42,7 @@ public:
|
|||
|
||||
private:
|
||||
static const Glib::ustring Change_UUID_Warning [] ;
|
||||
const Glib::ustring pad_label( const Glib::ustring &label ) const ;
|
||||
};
|
||||
|
||||
} //GParted
|
||||
|
|
16
src/fat16.cc
16
src/fat16.cc
|
@ -180,7 +180,7 @@ bool fat16::write_label( const Partition & partition, OperationDetail & operatio
|
|||
if ( partition .get_label() .empty() )
|
||||
cmd = "mlabel -c :: -i " + partition.get_path();
|
||||
else
|
||||
cmd = "mlabel ::\"" + partition.get_label() + "\" -i " + partition.get_path();
|
||||
cmd = "mlabel ::\"" + pad_label( partition.get_label() ) + "\" -i " + partition.get_path();
|
||||
|
||||
operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
|
||||
|
||||
|
@ -235,7 +235,7 @@ bool fat16::write_uuid( const Partition & partition, OperationDetail & operation
|
|||
bool fat16::create( const Partition & new_partition, OperationDetail & operationdetail )
|
||||
{
|
||||
Glib::ustring fat_size = specific_type == FS_FAT16 ? "16" : "32" ;
|
||||
return ! execute_command( "mkdosfs -F" + fat_size + " -v -I -n \"" + new_partition .get_label() +
|
||||
return ! execute_command( "mkdosfs -F" + fat_size + " -v -I -n \"" + pad_label( new_partition .get_label() ) +
|
||||
"\" " + new_partition .get_path(),
|
||||
operationdetail,
|
||||
false,
|
||||
|
@ -250,6 +250,14 @@ bool fat16::check_repair( const Partition & partition, OperationDetail & operati
|
|||
return ( exit_status == 0 || exit_status == 1 || exit_status == 256 ) ;
|
||||
}
|
||||
|
||||
//Private methods
|
||||
|
||||
//Pad fat label with spaces to prevent mlabel writing corrupted labels. See bug #700228
|
||||
const Glib::ustring fat16::pad_label( const Glib::ustring &label ) const
|
||||
{
|
||||
Glib::ustring new_label = label ;
|
||||
new_label .resize( Utils::get_filesystem_label_maxlength( specific_type ), ' ' ) ;
|
||||
return new_label ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue