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:
Milan Broz
2011-08-22 21:53:38 +00:00
parent c5b64b5479
commit 906c7897e1
2 changed files with 10 additions and 7 deletions

View File

@@ -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;
}