mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Fix handling of too long label and subsystem fields
These LUKS2 labels are stored in the binary header area that has limited size. While we have been silently truncating strings here, it is something that is not expected, as the final label is then different than expected. Let's fix the code to explicitly print and return error here. Also remove the comment about duplicate check. It is incorrect optimization, as some users will expect a real write on disk, we should no skip it. Fixes: #958
This commit is contained in:
@@ -1272,7 +1272,11 @@ int LUKS2_hdr_uuid(struct crypt_device *cd, struct luks2_hdr *hdr, const char *u
|
||||
int LUKS2_hdr_labels(struct crypt_device *cd, struct luks2_hdr *hdr,
|
||||
const char *label, const char *subsystem, int commit)
|
||||
{
|
||||
//FIXME: check if the labels are the same and skip this.
|
||||
if ((label && strlen(label) >= LUKS2_LABEL_L) ||
|
||||
(subsystem && strlen(subsystem) >= LUKS2_LABEL_L)) {
|
||||
log_err(cd, _("Label is too long."));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memset(hdr->label, 0, LUKS2_LABEL_L);
|
||||
if (label)
|
||||
|
||||
Reference in New Issue
Block a user