[PATCH 07/13] fscrypto: simplify building key descriptor string

From: Eric Biggers
Date: Sun Apr 03 2016 - 01:26:03 EST


Signed-off-by: Eric Biggers <ebiggers3@xxxxxxxxx>
---
fs/crypto/keyinfo.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index cb06351..5fcee4d 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -164,13 +164,8 @@ retry:
memset(raw_key, 0x42, FS_AES_256_XTS_KEY_SIZE);
goto got_key;
}
- memcpy(full_key_descriptor, FS_KEY_DESC_PREFIX,
- FS_KEY_DESC_PREFIX_SIZE);
- sprintf(full_key_descriptor + FS_KEY_DESC_PREFIX_SIZE,
- "%*phN", FS_KEY_DESCRIPTOR_SIZE,
- ctx.master_key_descriptor);
- full_key_descriptor[FS_KEY_DESC_PREFIX_SIZE +
- (2 * FS_KEY_DESCRIPTOR_SIZE)] = '\0';
+ sprintf(full_key_descriptor, FS_KEY_DESC_PREFIX "%*phN",
+ FS_KEY_DESCRIPTOR_SIZE, ctx.master_key_descriptor);
keyring_key = request_key(&key_type_logon, full_key_descriptor, NULL);
if (IS_ERR(keyring_key)) {
res = PTR_ERR(keyring_key);
--
2.7.4