mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-06 00:10:04 +01:00
LUKS header and Type needs to be set in context before crypt_check_data_device_size() is called.
(Thanks to okozina@redhat.com) git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@600 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
16
lib/setup.c
16
lib/setup.c
@@ -913,15 +913,17 @@ int crypt_load(struct crypt_device *cd,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = crypt_check_data_device_size(cd);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (!cd->type && !(cd->type = strdup(CRYPT_LUKS1)))
|
||||
return -ENOMEM;
|
||||
|
||||
memcpy(&cd->hdr, &hdr, sizeof(hdr));
|
||||
free(cd->type);
|
||||
cd->type = strdup(CRYPT_LUKS1);
|
||||
if (!cd->type)
|
||||
r = -ENOMEM;
|
||||
|
||||
/* cd->type and header must be set in context */
|
||||
r = crypt_check_data_device_size(cd);
|
||||
if (r < 0) {
|
||||
free(cd->type);
|
||||
cd->type = NULL;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user