Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 230666
b: refs/heads/master
c: 69a8cfc
h: refs/heads/master
v: v3
  • Loading branch information
Milan Broz authored and Alasdair G Kergon committed Jan 13, 2011
1 parent b87a368 commit bcb021d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 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: 4a1aeb98297e17f4e0a8cdda919e63bf528b2e5d
refs/heads/master: 69a8cfcda21017364df1c21b720daf304b5598a6
13 changes: 7 additions & 6 deletions trunk/drivers/md/dm-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,15 +973,15 @@ static void crypt_encode_key(char *hex, u8 *key, unsigned int size)

static int crypt_set_key(struct crypt_config *cc, char *key)
{
unsigned key_size = strlen(key) >> 1;

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

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

if ((!key_size && strcmp(key, "-")) ||
(key_size && crypt_decode_key(cc->key, key, key_size) < 0))
if (cc->key_size && crypt_decode_key(cc->key, key, cc->key_size) < 0)
return -EINVAL;

set_bit(DM_CRYPT_KEY_VALID, &cc->flags);
Expand Down Expand Up @@ -1194,6 +1194,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
ti->error = "Cannot allocate encryption context";
return -ENOMEM;
}
cc->key_size = key_size;

ti->private = cc;
ret = crypt_ctr_cipher(ti, argv[0], argv[1]);
Expand Down

0 comments on commit bcb021d

Please sign in to comment.