mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2026-01-06 23:45:31 +01:00
Error handling improvement thanks to Erik Edin.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@28 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
@@ -50,6 +50,7 @@ static inline int round_up_modulo(int x, int m) {
|
||||
struct luks_masterkey *LUKS_alloc_masterkey(int keylength)
|
||||
{
|
||||
struct luks_masterkey *mk=malloc(sizeof(*mk) + keylength);
|
||||
if(NULL == mk) return NULL;
|
||||
mk->keyLength=keylength;
|
||||
return mk;
|
||||
}
|
||||
@@ -66,7 +67,13 @@ void LUKS_dealloc_masterkey(struct luks_masterkey *mk)
|
||||
struct luks_masterkey *LUKS_generate_masterkey(int keylength)
|
||||
{
|
||||
struct luks_masterkey *mk=LUKS_alloc_masterkey(keylength);
|
||||
getRandom(mk->key,keylength);
|
||||
if(NULL == mk) return NULL;
|
||||
|
||||
int r = getRandom(mk->key,keylength);
|
||||
if(r < 0) {
|
||||
LUKS_dealloc_masterkey(mk);
|
||||
return NULL;
|
||||
}
|
||||
return mk;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user