ecryptfs: fix string overflow on long cipher names
authorEric Sandeen <sandeen@redhat.com>
Sat, 22 Dec 2007 22:03:24 +0000 (14:03 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Sun, 23 Dec 2007 20:54:36 +0000 (12:54 -0800)
Passing a cipher name > 32 chars on mount results in an overflow when the
cipher name is printed, because the last character in the struct
ecryptfs_key_tfm's cipher_name string was never zeroed.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Acked-by: Michael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ecryptfs/crypto.c

index bbed2fd40fdcd59d125e269afde868880c495724..67e8b16f7bcb752215a8ac235a7090e2616e14ef 100644 (file)
@@ -1847,6 +1847,7 @@ ecryptfs_add_new_key_tfm(struct ecryptfs_key_tfm **key_tfm, char *cipher_name,
        mutex_init(&tmp_tfm->key_tfm_mutex);
        strncpy(tmp_tfm->cipher_name, cipher_name,
                ECRYPTFS_MAX_CIPHER_NAME_SIZE);
+       tmp_tfm->cipher_name[ECRYPTFS_MAX_CIPHER_NAME_SIZE] = '\0';
        tmp_tfm->key_size = key_size;
        rc = ecryptfs_process_key_cipher(&tmp_tfm->key_tfm,
                                         tmp_tfm->cipher_name,