(Thanks to okozina@redhat.com)
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@600
36d66b0a-2a48-0410-832c-
cd162a569da5
2011-08-22 Milan Broz <mbroz@redhat.com>
* Add more paranoid checks for LUKS header and keyslot attributes.
+ * Fix crypt_load to properly check device size.
2011-07-25 Milan Broz <mbroz@redhat.com>
* Remove hash/hmac restart from crypto backend and make it part of hash/hmac final.
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;
}