Subject: [PATCH 2.6.32 03/12] eCryptfs: Remove buggy and unnecessary write in file name decode routine

From: Michael Halcrow <[email-masked]>
Date: Wed, 26 Nov 2014 09:09:16 -0800

commit 942080643bce061c3dd9d5718d3b745dcb39a8bc upstream.

Dmitry Chernenkov used KASAN to discover that eCryptfs writes past the
end of the allocated buffer during encrypted filename decoding. This
fix corrects the issue by getting rid of the unnecessary 0 write when
the current bit offset is 2.

Signed-off-by: Michael Halcrow <[email-masked]>
Reported-by: Dmitry Chernenkov <[email-masked]>
Suggested-by: Kees Cook <[email-masked]>
Signed-off-by: Tyler Hicks <[email-masked]>
Signed-off-by: Ben Hutchings <[email-masked]>
---
 fs/ecryptfs/crypto.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 7e164bb..cc57904 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -2088,7 +2088,6 @@ ecryptfs_decode_from_filename(unsigned char *dst, size_t *dst_size,
 			break;
 		case 2:
 			dst[dst_byte_offset++] |= (src_byte);
-			dst[dst_byte_offset] = 0;
 			current_bit_offset = 0;
 			break;
 		}