[PATCH 1/9] jfs: ensure symlinks are NUL-terminated

[email protected] Wed, 17 Jun 2009 08:44:30 -0500 (CDT)
Newsgroups gmane.comp.file-systems.jfs.patches
Message-ID <[email protected]>
commit 0cfc421f4e74e88bcf30cb50563e41d9368d1655
Author: Dave Kleikamp <[email protected]>
Date:   Tue Dec 16 10:12:59 2008 -0600

    jfs: ensure symlinks are NUL-terminated
    
    This is an alternate fix for a bug reported and fixed by Duane Griffin.
    
    Signed-off-by: Dave Kleikamp <[email protected]>
    Reported-by: Duane Griffin <[email protected]>

diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 2103397..b00ee9f 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -59,8 +59,14 @@ struct inode *jfs_iget(struct super_block *sb, unsigned long ino)
 		if (inode->i_size >= IDATASIZE) {
 			inode->i_op = &page_symlink_inode_operations;
 			inode->i_mapping->a_ops = &jfs_aops;
-		} else
+		} else {
 			inode->i_op = &jfs_symlink_inode_operations;
+			/*
+			 * The inline data should be null-terminated, but
+			 * don't let on-disk corruption crash the kernel
+			 */
+			JFS_IP(inode)->i_inline[inode->i_size] = '\0';
+		}
 	} else {
 		inode->i_op = &jfs_file_inode_operations;
 		init_special_inode(inode, inode->i_mode, inode->i_rdev);

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects