Bug 254142

Summary: gpart silently truncates the GPT label
Product: Base System Reporter: rashey
Component: binAssignee: freebsd-geom (Nobody) <geom>
Status: New ---    
Severity: Affects Some People CC: fbsd-bugzilla
Priority: ---    
Version: 13.0-STABLE   
Hardware: amd64   
OS: Any   

Description rashey 2021-03-08 19:56:48 UTC
If a specified label is too long for the GPT scheme, gpart silently truncates it and does not return an error.

# freebsd-version
13.0-RC1
# gpart create -s GPT da1
da1 created
# gpart add -t freebsd-ufs -l 12345678901234567890123456789012345678901234567890 da1
da1p1 added
# echo $?
0
# gpart show -l da1
=>     40  8388528  da1  GPT  (4.0G)
       40  8388528    1  123456789012345678901234567890123456  (4.0G)
Comment 1 David Schlachter 2021-03-11 01:56:32 UTC
Partition names (labels) are limited to 36 characters in GPT. Wikipedia has a nice breakdown of the format of the partition entries where you can see this: https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries_(LBA_2–33)

I tried your example, and inspecting the GPT partition table on-disk with a hex editor, e.g.

   doas cat /dev/da1 | xxd | less

I can see that the label is 123456789012345678901234567890123456, as displayed by gpart (first 36 characters of the label you had tried to assign).

The bug here would be that gpart doesn't complain about the label being too long in `gpart add`.