lib: harden checks for null name in resume/suspend

This commit is contained in:
Ondrej Kozina
2017-06-23 16:55:22 +02:00
committed by Milan Broz
parent 198f1d10c4
commit 10bb186c76

View File

@@ -1598,6 +1598,9 @@ int crypt_suspend(struct crypt_device *cd,
crypt_status_info ci;
int r;
if (!name)
return -EINVAL;
log_dbg("Suspending volume %s.", name);
if (cd->type) {
@@ -1648,15 +1651,15 @@ int crypt_resume_by_passphrase(struct crypt_device *cd,
struct volume_key *vk = NULL;
int r;
log_dbg("Resuming volume %s.", name);
r = onlyLUKS(cd);
if (r < 0)
return r;
if (!passphrase)
if (!passphrase || !name)
return -EINVAL;
log_dbg("Resuming volume %s.", name);
r = dm_status_suspended(cd, name);
if (r < 0)
return r;
@@ -1694,12 +1697,15 @@ int crypt_resume_by_keyfile_offset(struct crypt_device *cd,
size_t passphrase_size_read;
int r;
log_dbg("Resuming volume %s.", name);
r = onlyLUKS(cd);
if (r < 0)
return r;
if (!name)
return -EINVAL;
log_dbg("Resuming volume %s.", name);
r = dm_status_suspended(cd, name);
if (r < 0)
return r;