Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 242561
b: refs/heads/master
c: de8be5a
h: refs/heads/master
i:
  242559: c88e064
v: v3
  • Loading branch information
Milan Broz authored and Alasdair G Kergon committed Mar 24, 2011
1 parent b21fdb9 commit cc6bbfc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3407ef5262b55ca5d7139d2b555ef792fe531eec
refs/heads/master: de8be5ac70f50a2340f24fd769a1aafa5a51ae34
19 changes: 14 additions & 5 deletions trunk/drivers/md/dm-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1331,20 +1331,29 @@ static int crypt_setkey_allcpus(struct crypt_config *cc)

static int crypt_set_key(struct crypt_config *cc, char *key)
{
int r = -EINVAL;
int key_string_len = strlen(key);

/* The key size may not be changed. */
if (cc->key_size != (strlen(key) >> 1))
return -EINVAL;
if (cc->key_size != (key_string_len >> 1))
goto out;

/* Hyphen (which gives a key_size of zero) means there is no key. */
if (!cc->key_size && strcmp(key, "-"))
return -EINVAL;
goto out;

if (cc->key_size && crypt_decode_key(cc->key, key, cc->key_size) < 0)
return -EINVAL;
goto out;

set_bit(DM_CRYPT_KEY_VALID, &cc->flags);

return crypt_setkey_allcpus(cc);
r = crypt_setkey_allcpus(cc);

out:
/* Hex key string not needed after here, so wipe it. */
memset(key, '0', key_string_len);

return r;
}

static int crypt_wipe_key(struct crypt_config *cc)
Expand Down

0 comments on commit cc6bbfc

Please sign in to comment.