Browse Source

eCryptfs: Regression in unencrypted filename symlinks

The addition of filename encryption caused a regression in unencrypted
filename symlink support.  ecryptfs_copy_filename() is used when dealing
with unencrypted filenames and it reported that the new, copied filename
was a character longer than it should have been.

This caused the return value of readlink() to count the NULL byte of the
symlink target.  Most applications don't care about the extra NULL byte,
but a version control system (bzr) helped in discovering the bug.

Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Tyler Hicks 16 years ago
parent
commit
fd9fc842bb
1 changed files with 2 additions and 2 deletions
  1. 2 2
      fs/ecryptfs/crypto.c

+ 2 - 2
fs/ecryptfs/crypto.c

@@ -1716,7 +1716,7 @@ static int ecryptfs_copy_filename(char **copied_name, size_t *copied_name_size,
 {
 {
 	int rc = 0;
 	int rc = 0;
 
 
-	(*copied_name) = kmalloc((name_size + 2), GFP_KERNEL);
+	(*copied_name) = kmalloc((name_size + 1), GFP_KERNEL);
 	if (!(*copied_name)) {
 	if (!(*copied_name)) {
 		rc = -ENOMEM;
 		rc = -ENOMEM;
 		goto out;
 		goto out;
@@ -1726,7 +1726,7 @@ static int ecryptfs_copy_filename(char **copied_name, size_t *copied_name_size,
 						 * in printing out the
 						 * in printing out the
 						 * string in debug
 						 * string in debug
 						 * messages */
 						 * messages */
-	(*copied_name_size) = (name_size + 1);
+	(*copied_name_size) = name_size;
 out:
 out:
 	return rc;
 	return rc;
 }
 }