Skip to content

Fix crash when dealing with 0000-0000 exfat UUID

Marcin Zepp requested to merge nircek/gparted:fix-exfat-crash into master

Gparted crashes when blkid doesn't provide the UUID of the exfat partition and its serial has preceding zeroes (and it isn't mounted).

The blkid doesn't report UUID if (and only?) the serial number is 0000-0000 (a.k.a. 0x0).

Steps to reproduce:

$ truncate -s 4M /tmp/disk.img
$ losetup -f --show /tmp/disk.img
/dev/loop0
$ mkfs.exfat /dev/loop0
[...]
exFAT format complete!
$ partprobe /dev/loop0 
$ blkid /dev/loop0
/dev/loop0: UUID="F7BF-ABFF" BLOCK_SIZE="512" TYPE="exfat" PTTYPE="dos"
$ exfatlabel /dev/loop0 -i 0x0
exfatprogs version : 1.1.3
New volume serial : 0x0
$ partprobe /dev/loop0
$ blkid /dev/loop0
/dev/loop0: BLOCK_SIZE="512" TYPE="exfat" PTTYPE="dos"
$ gparted /dev/loop0
GParted 1.3.1
configuration --enable-libparted-dmraid --enable-online-resize
libparted 3.4

** (gpartedbin:94926): ERROR **: 10:45:01.894: 
unhandled exception (type std::exception) in signal handler:
what: basic_string::assign: __pos (which is 18446744073709551615) > this->size() (which is 3)

Trace/breakpoint trap (core dumped)
$ losetup -d /dev/loop0; rm /tmp/disk.img

The FS_Info::run_blkid_load_cache will not cache UUID, and GParted_Core::set_partition_label_and_uuid will call GParted_Core::read_uuid and it will call exfat::read_uuid.

Then the tune.exfat -i /dev/loop0 will be executed:

$ tune.exfat -i /dev/sdb1
exfatprogs version : 1.1.3
volume serial : 0x0

And exfat::serial_to_blkid_uuid will be called with argument 0x0, which will fail.

Merge request reports